Networking

CloudFront Functions & Lambda@Edge

Serverless compute running at AWS edge locations to customize and transform CloudFront web traffic close to users.

How it works

CloudFront Functions and Lambda@Edge run code in response to CloudFront events. CloudFront Functions suits lightweight JavaScript operations such as URL rewrites and header changes on viewer requests or responses. Lambda@Edge supports more complex processing, including network access and optional request body access on supported request triggers. Their runtimes, event types, and quotas differ.

When to use it

Choose it when the requirement is edge customization: CloudFront Functions for lightweight header/URL changes, or Lambda@Edge for network or body access.

Real-world example

A media company uses CloudFront Functions to normalize URLs. It uses Lambda@Edge on viewer requests to check a member session against an external service before delivering protected content.

Key facts

  • CloudFront Functions executes in under 1 ms with 2 MB memory for viewer request and response triggers.
  • Lambda@Edge supports network calls and request body access and is created in us-east-1; quotas depend on the event type.

Common pitfall

CloudFront Functions cannot make arbitrary network calls or access the request body. For those requirements, consider Lambda@Edge with a suitable trigger and check its quotas and security requirements.

Often confused with

A standard AWS Lambda function, which runs in a specific AWS Region rather than at global CloudFront edge locations.

References

Prepared by Cloud Quest. Check current behavior and limits in the AWS documentation:

SAA-C03 study guide and learning resources

Keywords you will see in SAA-C03 questions

  • edge compute
  • CloudFront viewer request
  • URL rewrite
  • header manipulation

Understand it for real with 3D models and simulated labs

Connect the concept to a working architecture.

Start learning