LambdaEdgeEventType

class aws_cdk.aws_cloudfront.LambdaEdgeEventType(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)

Bases: Enum

The type of events that a Lambda@Edge function can be invoked in response to.

ExampleMetadata:

infused

Example:

# my_bucket: s3.Bucket
# A Lambda@Edge function added to default behavior of a Distribution
# and triggered on every request
my_func = cloudfront.experimental.EdgeFunction(self, "MyFunction",
    runtime=lambda_.Runtime.NODEJS_LATEST,
    handler="index.handler",
    code=lambda_.Code.from_asset(path.join(__dirname, "lambda-handler"))
)
cloudfront.Distribution(self, "myDist",
    default_behavior=cloudfront.BehaviorOptions(
        origin=origins.S3Origin(my_bucket),
        edge_lambdas=[cloudfront.EdgeLambda(
            function_version=my_func.current_version,
            event_type=cloudfront.LambdaEdgeEventType.VIEWER_REQUEST
        )
        ]
    )
)

Attributes

ORIGIN_REQUEST

The origin-request specifies the request to the origin location (e.g. S3).

ORIGIN_RESPONSE

The origin-response specifies the response from the origin location (e.g. S3).

VIEWER_REQUEST

The viewer-request specifies the incoming request.

VIEWER_RESPONSE

The viewer-response specifies the outgoing response.