AWS Lambda@Edge

Instruction: Discuss how AWS Lambda@Edge works and its use cases.

Context: This question evaluates the candidate's knowledge of AWS Lambda@Edge, including its integration with Amazon CloudFront, use cases for content customization and security, and the differences from standard AWS Lambda functions.

Updated

Example Answer

Lambda@Edge runs functions associated with CloudFront events. The event matters: a viewer-request function runs before the cache lookup, while an origin-request function runs when CloudFront forwards to the origin and does not run for a cache hit. I would choose the earliest necessary hook without adding work to every request unnecessarily. For example, a simple redirect and an origin-selection rule have different placement needs. I would also review cache keys carefully so personalized content cannot be shared across users. The function must be published as a numbered version in us-east-1; aliases and $LATEST cannot be associated.

Placement check

Compare a cache hit and a cache miss in a test distribution and confirm which trigger executes. Viewer-response and origin-response events have different conditions too; they are not interchangeable.

Lambda@Edge has restrictions beyond regional Lambda, including no provisioned concurrency, layers, or container-image deployment. Keep the edge task small and check current runtime support. For simpler viewer-request or viewer-response JavaScript transformations, evaluate CloudFront Functions against the required capabilities and limits.

Practice follow-up

How would a cookie-dependent response affect the cache key and the risk of cross-user data exposure?

Sources

CloudFront Lambda trigger events; Lambda@Edge restrictions.

Related Questions