I can find nothing in the docs explaining this issue. I followed this blog post pretty much to the T: https://aws.amazon.com/blogs/networking-and-content-delivery/managing-lambdaedge-and-cloudfront-deployments-by-using-a-ci-cd-pipeline/
It works as expected but I wanted to add another event for viewer-request so I can test my function immediately without waiting for the object to expire
I added this to the template:
LambdaFunctionAssociations:
-
EventType: origin-request
LambdaFunctionARN: !Ref LambdaEdgeFunctionSample.Version
# Adding this to hit my function on every user request
-
EventType: viewer-request
LambdaFunctionARN: !Ref LambdaEdgeFunctionSample.Version
This results in the following error:
The Lambda function associated with the CloudFront distribution is invalid or doesn't have the required permissions. We can't connect to the server for this app or website at this time. There might be too much traffic or a configuration error. Try again later, or contact the app or website owner. If you provide content to customers through CloudFront, you can find steps to troubleshoot and help prevent this error by reviewing the CloudFront documentation.
Im not sure why this is happening or how to even troubleshoot it. I know the function works because origin-request executes the function successfully.