In this section, you add CloudFront as a trigger for your Lambda function. Requests to the /serverless path go through the CloudFront distribution, which invokes the Lambda@Edge function on the Origin request event before forwarding the request to the origin.

Lambda@Edge functions must be created in the US East (N. Virginia) us-east-1 region. Make sure the region selector in the console shows United States (N. Virginia) before you continue.


Lambda@Edge has some restrictions: only Node.js and Python runtimes are supported, and environment variables, Dead Letter Queues (DLQ), and Amazon VPC cannot be used.

If the distribution or the /serverless cache behavior does not appear in the list, click the refresh button next to the field. If /serverless is still missing, go back and check that you created that cache behavior in the earlier section.

Lambda@Edge triggers always attach to a numbered function version, never to $LATEST. If you change the code later, you must publish a new version and update the trigger to use it.
CloudFront needs about 5 minutes to deploy the change to all edge locations. Wait until the distribution’s Last modified status in the CloudFront console changes from Deploying to a date before you test.


Lambda@Edge copies the function to AWS Regions that have a CloudFront Regional Edge Cache. The Replicas list only shows replicas in the region currently selected, so switch regions to see others. A replica usually appears in a region only after requests have been served there. Replicas are read-only, and you cannot edit or delete them directly.

If you get an error or old content, wait a few more minutes for the deployment to finish, then refresh. To check the function’s logs, open CloudWatch Logs in the region closest to you, not in us-east-1. Lambda@Edge writes logs in the region where the function ran, in a log group named /aws/lambda/us-east-1.LambdaEdgeImmersionDayLabFunction.