Lambda@Edge and Event-Driven Patterns
Run functions at CloudFront edge locations and connect Lambda to SQS, SNS, DynamoDB Streams, and Kinesis for event-driven architectures.
What Is Lambda@Edge?
Lambda@Edge lets you run Lambda functions at CloudFront edge locations around the world—closer to end users—rather than in a centralised Region. This enables you to customise HTTP requests and responses with sub-millisecond added latency at the CDN layer. Lambda@Edge functions are deployed globally and invoked on every CloudFront cache hit or miss event, making them ideal for lightweight request manipulation tasks.
The Four CloudFront Trigger Points
Lambda@Edge can intercept traffic at four points in the CloudFront request lifecycle:
- Viewer Request: fires when CloudFront receives a request from the viewer (user), before checking the cache
- Origin Request: fires when CloudFront forwards a cache miss to the origin
- Origin Response: fires when the origin returns a response before caching
- Viewer Response: fires before CloudFront returns the response to the viewer
All lessons in this course
- Lambda Functions: Runtimes, Triggers, and Handlers
- Concurrency, Throttling, and Reserved Concurrency
- Lambda Layers and Deployment Packages
- Lambda@Edge and Event-Driven Patterns