Get started with Lambda@Edge functions
With Lambda@Edge, you can use CloudFront triggers to invoke a Lambda function. When you associate a CloudFront distribution with a Lambda function, CloudFront intercepts requests and responses at CloudFront edge locations and runs the function. Lambda functions can improve security or customize information close to your viewers to improve performance.
The following list provides a basic overview of how to create and use Lambda functions with CloudFront.
Overview: Creating and using Lambda functions with CloudFront
-
Create a Lambda function in the US East (N. Virginia) Region.
-
Save and publish a numbered version of the function.
If you want to change the function, you must edit the $LATEST version of the function in the US East (N. Virginia) Region. Then, before you set it up to work with CloudFront, you publish a new numbered version.
-
Associate the function with a CloudFront distribution and cache behavior. Then specify one or more CloudFront events (triggers) that cause the function to execute. For example, you can create a trigger for the function to execute when CloudFront receives a request from a viewer.
-
When you create a trigger, Lambda creates replicas of the function at AWS locations around the world.
Tip
For more information, see creating and updating functions, the event structure, and adding CloudFront triggers. You can also find more ideas and get code samples in Lambda@Edge example functions.
For a step-by-step tutorial, see the following topic: