Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

lambda@edge not getting triggered with cloudfront

I am using lambda@edge to redirect my sites with cloudfront.

I have attached my versioned lambda arn to my cloud front cache behavior to all 4 events it has.

when i hit my cloudfront endpoint it says

502 ERROR
The request could not be satisfied.
The Lambda function returned invalid json: The json output must be an object type. 

when i check my lambda logs / invocation metrics i dont see any hits at all .

what may be the reason behind this ?

i tried my best to find the fix why my lambda is not getting triggered ??

like image 742
Vishnu Ranganathan Avatar asked Dec 11 '22 07:12

Vishnu Ranganathan


1 Answers

There are some common "gotchas" to Lambda@Edge and CloudFront. You need to:

  • Publish a new version of you Lambda function
  • Update the CloudFront Lambda association to your new version, e.g. arn:aws:lambda:us-east-1:572007530218:function:gofaas-WebAuthFunction:45
  • Look for Lambda@Edge logs in the region of the requestor

This is different from "normal" Lambda web console flow of saving a code change and jumping to logs from the monitoring tab.

like image 58
Noah Zoschke Avatar answered Dec 28 '22 13:12

Noah Zoschke