Lambda@Edge Function Not Triggering on CloudFront Viewer Request

0

What's Wrong: I have a Lambda@Edge function that is supposed to trigger on a CloudFront 'Viewer Request' event. The function is designed to perform A/B testing by routing traffic to one of two S3 buckets. However, the function is not being triggered when I access my site via CloudFront or directly through the domain name.

Steps Taken for Troubleshooting:

  • Verified that the Lambda function is deployed and associated with the correct CloudFront distribution.
  • Checked the CloudFront behavior settings to ensure that the Lambda function is set to trigger on 'Viewer Request'.
  • Created CloudFront invalidations multiple times to clear the cache.
  • Manually invoked the Lambda function from the AWS Console, and it executed successfully.
  • Checked CloudWatch logs and metrics; no logs or metrics are being generated for the Lambda function.
  • Reviewed the IAM role and trust policy for the Lambda function; it allows edgelambda.amazonaws.com and lambda.amazonaws.com to assume the role.
  • Deployed a simple test Lambda function that logs a message and associated it with the same CloudFront distribution. This test function also did not trigger.

Support Needed: Please help me identify why the Lambda@Edge function is not being triggered.

  • Are there any additional logs or metrics that can be accessed to diagnose the issue?
  • Is there any misconfiguration in my CloudFront distribution or Lambda function that is preventing the trigger?

Any other recommendations for troubleshooting this issue would be highly appreciated. Thank you for your assistance.

1 Answer
0

Hi,

About your Checked CloudWatch logs and metrics; no logs or metrics are being generated for the Lambda function., do you check them in the region closest to the requester? That's where they should appear. Indeed, it will be hard to help until you have some error logs.

You should also publish you CloudFormation template detailling the config to help us analyze your setup.

Best,

Didier

profile pictureAWS
EXPERT
answered 7 months ago
  • I didn't use a CloudFormation template. Is there a way to export what I've done?

    I checked all CloudWatch logs and they don't generate any data when I access the cloudfront URL externally. I DO get logs when I run a manual test within the Lambda UI itself, and that runs successfully.

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions