AWS Fundamentals Logo
AWS Fundamentals
AWS::CloudFront::Function

CloudFront Function

Creates 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.

Properties

6 configurable properties. 3 required. Click a row to see details.

Filter:
PropertyTypeFlags
FunctionCode
string
Required
FunctionConfig
FunctionConfig
Required
Name
string
RequiredCreate-only
AutoPublish
boolean
Write-only
FunctionMetadata
FunctionMetadata
Tags
Array<Tag>

Return Values

Values returned after the resource is created. Access these with Fn::GetAtt.

AttributeTypeDescription
FunctionARNstring-
Stagestring-

Sample CloudFormation Template

A minimal template with required properties and common optional ones.

template.yaml
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: Production

Required IAM Permissions

Permissions CloudFormation needs in your IAM role to manage this resource.

create

cloudfront:CreateFunctioncloudfront:PublishFunctioncloudfront:DescribeFunctioncloudfront:TagResource

delete

cloudfront:DeleteFunctioncloudfront:DescribeFunction

list

cloudfront:ListFunctions

read

cloudfront:DescribeFunctioncloudfront:GetFunctioncloudfront:ListTagsForResource

update

cloudfront:UpdateFunctioncloudfront:PublishFunctioncloudfront:DescribeFunctioncloudfront:TagResourcecloudfront:UntagResource

Get the CloudFront Cheat Sheet

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

Download Free Infographic

Quick Facts

ServiceCloudFront
Properties8
Required3
TaggingSupported
Primary IDFunctionARN

Supported Operations

CreateDeleteListReadUpdate

Immutable After Creation

These properties cannot be changed after the resource is created. Updating them triggers a replacement.

Name

External Links