AWS::CloudFront::Function - Amazon CloudFormation
Services or capabilities described in Amazon Web Services documentation might vary by Region. To see the differences applicable to the China Regions, see Getting Started with Amazon Web Services in China (PDF).


Creates a CloudFront function.

To create a function, you provide the function code and some configuration information about the function. The response contains an Amazon Resource Name (ARN) that uniquely identifies the function, and the function’s stage.

By default, when you create a function, it’s in the DEVELOPMENT stage. In this stage, you can test the function in the CloudFront console (or with TestFunction in the CloudFront API).

When you’re ready to use your function with a CloudFront distribution, publish the function to the LIVE stage. You can do this in the CloudFront console, with PublishFunction in the CloudFront API, or by updating the AWS::CloudFront::Function resource with the AutoPublish property set to true. When the function is published to the LIVE stage, you can attach it to a distribution’s cache behavior, using the function’s ARN.

To automatically publish the function to the LIVE stage when it’s created, set the AutoPublish property to true.


To declare this entity in your Amazon CloudFormation template, use the following syntax:


{ "Type" : "AWS::CloudFront::Function", "Properties" : { "AutoPublish" : Boolean, "FunctionCode" : String, "FunctionConfig" : FunctionConfig, "FunctionMetadata" : FunctionMetadata, "Name" : String } }


Type: AWS::CloudFront::Function Properties: AutoPublish: Boolean FunctionCode: String FunctionConfig: FunctionConfig FunctionMetadata: FunctionMetadata Name: String



A flag that determines whether to automatically publish the function to the LIVE stage when it’s created. To automatically publish to the LIVE stage, set this property to true.

Required: No

Type: Boolean

Update requires: No interruption


The function code. For more information about writing a CloudFront function, see Writing function code for CloudFront Functions in the Amazon CloudFront Developer Guide.

Required: Yes

Type: String

Update requires: No interruption


Contains configuration information about a CloudFront function.

Required: Yes

Type: FunctionConfig

Update requires: No interruption


Contains metadata about a CloudFront function.

Required: No

Type: FunctionMetadata

Update requires: No interruption


A name to identify the function.

Required: Yes

Type: String

Minimum: 1

Maximum: 64

Pattern: ^[a-zA-Z0-9-_]{1,64}$

Update requires: No interruption

Return values



The ARN of the function. For example:


To get the function ARN, use the following syntax:

!GetAtt Function_Logical_ID.FunctionMetadata.FunctionARN


The Amazon Resource Name (ARN) of the function. The ARN uniquely identifies the function.