Reputation: 4384
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".
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:
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:
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.
Upvotes: 0
Views: 750
Reputation: 4384
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.
Upvotes: 0