0
votes

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.

1

1 Answers

0
votes

Check your CloudWatch Log Group (find the region closest to where you made your request from, else you may need to poke around a bit).

One common reason for this can be when your viewer request doesn't yield a proper response.

Example response generation

Lambda@Edge doesn't reveal much in errors to the client, which is good from a security standpoint, but means you'll need to dig into CloudWatch to see what errors have occurred.

You may also be getting things like 5 second duration exceeding or the 128MB memory limit, I don't recall if they throw anything other than a 503.