FunctionEventType

class aws_cdk.aws_cloudfront.FunctionEventType(value)

Bases: enum.Enum

The type of events that a CloudFront function can be invoked in response to.

ExampleMetadata

infused

Example:

# s3_bucket is of type Bucket
# Add a cloudfront Function to a Distribution
cf_function = cloudfront.Function(self, "Function",
    code=cloudfront.FunctionCode.from_inline("function handler(event) { return event.request }")
)
cloudfront.Distribution(self, "distro",
    default_behavior=cloudfront.BehaviorOptions(
        origin=origins.S3Origin(s3_bucket),
        function_associations=[cloudfront.FunctionAssociation(
            function=cf_function,
            event_type=cloudfront.FunctionEventType.VIEWER_REQUEST
        )]
    )
)

Attributes

VIEWER_REQUEST

The viewer-request specifies the incoming request.

VIEWER_RESPONSE

The viewer-response specifies the outgoing response.