What could lead to " KeyError: 'Records' " in Lambda Edge?

Viewed 108
1 Answers

In reference to Request Events, this link says

The following topics show the structure of the object that CloudFront passes to a Lambda function for viewer and origin request events.

These events are described as

Viewer Request: The function executes when CloudFront receives a request from a viewer, before it checks to see whether the requested object is in the CloudFront cache.

Origin Request: The function executes only when CloudFront forwards a request to your origin. When the requested object is in the CloudFront cache, the function doesn’t execute.

So it seems like you may be invoking the lambda in a way that does not cause the request event to be sent. If you are testing in the lambda console, try invoking it from cloudfront.

Related