Writing content of a Lambda@Edge function
There are several resources to help you with writing Lambda@Edge functions:
-
To learn about the event structure to use with Lambda@Edge functions, see Lambda@Edge event structure.
-
To see examples of Lambda@Edge functions, such as functions for A/B testing and generating an HTTP redirect, see Lambda@Edge example functions.
The programming model for using Node.js or Python with Lambda@Edge is the same as using Lambda in an AWS Region. For more information, see Building Lambda functions with Node.js or Building Lambda functions with Python.
In your Lambda@Edge code, include the callback
parameter and return the applicable object for
request or response events:
-
Request events – Include the
cf.request
object in the response.If you're generating a response, include the
cf.response
object in the response. For more information, see Generating HTTP responses in request triggers. -
Response events – Include the
cf.response
object in the response.