FunctionRuntime

class aws_cdk.aws_cloudfront.FunctionRuntime(*args: Any, **kwargs)

Bases: object

The function’s runtime environment version.

ExampleMetadata:

infused

Example:

# s3_bucket: s3.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 }"),
    runtime=cloudfront.FunctionRuntime.JS_2_0
)
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

JS_1_0 = <aws_cdk.aws_cloudfront.FunctionRuntime object>
JS_2_0 = <aws_cdk.aws_cloudfront.FunctionRuntime object>
value

Static Methods

classmethod custom(runtime_string)

A custom runtime string.

Gives full control over the runtime string fragment.

Parameters:

runtime_string (str) –

Return type:

FunctionRuntime