AWS::CloudFront::FunctionCreates a CF 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](https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/test-function.html) in the CF console (or with TestFunction in the CF API). When you’re ready to use your function with a CF distribution, publish the function to the LIVE stage. You can do this in the CF console, with PublishFunction in the CF 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.
6 configurable properties. 3 required. Click a row to see details.
| Property | Type | Flags |
|---|---|---|
FunctionCode | string | Required |
FunctionConfig | FunctionConfig | Required |
Name | string | RequiredCreate-only |
AutoPublish | boolean | Write-only |
FunctionMetadata | FunctionMetadata | |
Tags | Array<Tag> |
Values returned after the resource is created. Access these with Fn::GetAtt.
| Attribute | Type | Description |
|---|---|---|
FunctionARN | string | - |
Stage | string | - |
A minimal template with required properties and common optional ones.
AWSTemplateFormatVersion: "2010-09-09"
Description: Sample template for AWS::CloudFront::Function
Resources:
MyResource:
Type: AWS::CloudFront::Function
Properties:
Name: "my-name"
FunctionConfig: "value"
FunctionCode: "value"
Tags:
- Key: Environment
Value: ProductionPermissions CloudFormation needs in your IAM role to manage this resource.
cloudfront:CreateFunctioncloudfront:PublishFunctioncloudfront:DescribeFunctioncloudfront:TagResourcecloudfront:DeleteFunctioncloudfront:DescribeFunctioncloudfront:ListFunctionscloudfront:DescribeFunctioncloudfront:GetFunctioncloudfront:ListTagsForResourcecloudfront:UpdateFunctioncloudfront:PublishFunctioncloudfront:DescribeFunctioncloudfront:TagResourcecloudfront:UntagResourceEverything you need to know about CloudFront on one page. HD quality, print-friendly.
Download Free InfographicFunctionARNThese properties cannot be changed after the resource is created. Updating them triggers a replacement.
Name