Writing Functions for Lambda@Edge
There are several resources to help you with writing Lambda@Edge functions:
-
For more information about writing Lambda functions that you can use with Lambda@Edge, see Requirements and Restrictions on Lambda 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 with Lambda@Edge is the same as using Lambda in an AWS Region. For more information, see Programming Model(Node.js).
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.