Skip to content
v2.274.0

FunctionProps Struct ​

Properties for creating a CloudFront Function.

Example ​

ts
const store = new cloudfront.KeyValueStore(this, 'KeyValueStore');
new cloudfront.Function(this, 'Function', {
  code: cloudfront.FunctionCode.fromInline('function handler(event) { return event.request }'),
  // Note that JS_2_0 must be used for Key Value Store support
  runtime: cloudfront.FunctionRuntime.JS_2_0,
  keyValueStore: store,
});

Properties ​

autoPublishoptionalbooleanauto_publishoptionalboolautoPublishoptionalBooleanAutoPublishoptionalboolAutoPublishoptional*bool= true#
A flag that determines whether to automatically publish the function to the LIVE stage when it’s created.
The source code of the function.
commentoptionalstringcommentoptionalstrcommentoptionalStringCommentoptionalstringCommentoptional*string#
A comment to describe the function.

Default: same as functionName

functionNameoptionalstringfunction_nameoptionalstrfunctionNameoptionalStringFunctionNameoptionalstringFunctionNameoptional*string#
A name to identify the function.

Default: generated from the id

keyValueStoreoptionalIKeyValueStoreRefkey_value_storeoptionalIKeyValueStoreRefkeyValueStoreoptionalIKeyValueStoreRefKeyValueStoreoptionalIKeyValueStoreRefKeyValueStoreoptionalIKeyValueStoreRef#
The Key Value Store to associate with this function.

Default: no key value store is associated

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

runtimeoptionalFunctionRuntimeruntimeoptionalFunctionRuntimeruntimeoptionalFunctionRuntimeRuntimeoptionalFunctionRuntimeRuntimeoptionalFunctionRuntime#
The runtime environment for the function.

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