AWS Fundamentals Logo
AWS Fundamentals
L2 Construct

Function

A CloudFront Function.

Import

import { Function } from 'aws-cdk-lib/aws-cloudfront';

Or use the module namespace:

import * as cloudfront from 'aws-cdk-lib/aws-cloudfront';
// cloudfront.Function

Properties

Configuration passed to the constructor as FunctionProps.

codeRequired
FunctionCode

The source code of the function.

autoPublishOptional
boolean

A flag that determines whether to automatically publish the function to the LIVE stage when it’s created.

Default: - true

commentOptional
string

A comment to describe the function.

Default: - same as `functionName`

functionNameOptional
string

A name to identify the function.

Default: - generated from the `id`

keyValueStoreOptional
IKeyValueStoreRef

The Key Value Store to associate with this function. In order to associate a Key Value Store, the `runtime` must be `cloudfront-js-2.0` or newer.

Default: - no key value store is associated

runtimeOptional
FunctionRuntime

The runtime environment for the function.

Default: FunctionRuntime.JS_1_0 (unless `keyValueStore` is specified, then `FunctionRuntime.JS_2_0`)

Get the Amazon CloudFront Cheat Sheet

Everything you need to know about Amazon CloudFront on one page. HD quality, print-friendly.

Download Free Infographic