What is Lambda@Edge?

Lambda@Edge is an AWS service that allows you to run Lambda functions at AWS Edge locations globally. It is designed to customize the behavior of CloudFront distributions, enabling low-latency execution of code closer to users.

Key Features of Lambda@Edge

  1. Global Execution: Executes code at AWS edge locations near the user for low latency.
  2. Event-Driven: Integrates with CloudFront events (viewer requests, origin requests, viewer responses, origin responses).
  3. No Servers to Manage: Fully serverless; AWS manages scaling and infrastructure.
  4. Supports Multiple Use Cases:

Integration Points

Lambda@Edge integrates directly with CloudFront events:

Best Practices

  1. Use Lightweight Functions:
  2. Avoid Long-Running Tasks:
  3. Securely Handle Sensitive Data:

Example Scenarios

  1. Dynamic Content Localization:
  2. Header-Based Caching: