Lambda@Edge

Lambda@Edge is similar to Lambda in that it can run code without provisioning any servers but is different in that the code is replicated globally and therefore triggered globally. Lambda@Edge must be triggered from Cloudfront. Lambda@Edge is optimized for latency and is run from the Cloudfront edge locations. This improves the performance of the request since all necessary information is available in Cloudfront Edge and within the Lambda function running at the edge location.

It is easy to setup Lambda@Edge. Code needs to be written using NodeJS and be deployed to Lambda and Cloudfront needs to be selected as the trigger. Note that code must be written using NodeJS - other languages are not supported yet - and it can only be triggered using Cloudfront.

Lambda@Edge functions can be created and deployed in the same way as a regular lambda function. The only difference is Cloudfront has be selected as the trigger. Once selected, the "enable trigger and replicate" option needs to be selected as showb below.

Note that Lambda@Edge is different from api gateway since api gateway is regional whereas Lambda@Edge is global.