0

I'm using a Lambda function URL as the origin for a CloudFront distribution. FYI the Lambda function uses Go 1.20 (on provided.al2 and Arm64). Seems to work fine, but I CANNOT retrieve query parameters in code when making request, for example "https://www.example.com?test=1234".

CloudWatch logs sample: enter image description here

Sample of the Object I'm dumping the event into:

type Request struct {
    Context               Context        `json:"context"`
    Version               string         `json:"version"`
    RouteKey              string         `json:"routeKey"`
    RawPath               string         `json:"rawPath"`
    RawQueryString        string         `json:"rawQueryString"`
    Cookies               []string       `json:"cookies"`
    Headers               cli.StringMap  `json:"headers"`
    QueryStringParameters cli.StringMap  `json:"queryStringParameters"`
    QueryString           cli.StringMap  `json:"querystring"`
    RequestContext        RequestContext `json:"requestContext"`
    Body                  string         `json:"body"`
    PathParameters        interface{}    `json:"pathParameters"`
    IsBase64Encoded       bool           `json:"isBase64Encoded"`
    StageVariables        interface{}    `json:"stageVariables"`
}

Though I should switch to this: https://github.com/aws/aws-lambda-go/blob/v1.41.0/events/lambda_function_urls.go#L14C39-L14C39

Yes I have allowed all query strings in my CloudFront Request policy:

enter image description here

I have also removed any CloudFront and Lambda@Edge functions until I get pass this.

Problem is that I'm not sure which event Request format is in use when CloudFront invokes the Lambda Function URL. Any AWS documentation I've read so far has not made it clear. I have multiple choices:

  1. https://docs.aws.amazon.com/lambda/latest/dg/urls-invocation.html#urls-payloads
  2. https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/functions-event-structure.html

I also don't see an official CloudFront event that I can use in the official AWS Lambda Go Package here at https://pkg.go.dev/github.com/aws/aws-lambda-go/events#section-readme.

1 Answer 1

0

What you can do is use the official from AWS Lambda Function urls types. I deleted my Request type in favors of the request and response types and things started to work.

I disabled the CloudFront cache then then updated the Lambda Package and it all started to work.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.