Skip to content

CloudFront  >  Operations  >  create_function

create_function

Operation

create_function async

create_function(input: CreateFunctionInput, plugins: list[Plugin] | None = None) -> CreateFunctionOutput

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.

When you create a function, it's in the DEVELOPMENT stage. In this stage, you can test the function with TestFunction, and update it with UpdateFunction.

When you're ready to use your function with a CloudFront distribution, use PublishFunction to copy the function from the DEVELOPMENT stage to LIVE. When it's live, you can attach the function to a distribution's cache behavior, using the function's ARN.

Parameters:

Name Type Description Default
input CreateFunctionInput

An instance of CreateFunctionInput.

required
plugins list[Plugin] | None

A list of callables that modify the configuration dynamically. Changes made by these plugins only apply for the duration of the operation execution and will not affect any other operation invocations.

None

Returns:

Type Description
CreateFunctionOutput

An instance of CreateFunctionOutput.

Input

CreateFunctionInput dataclass

Bases: _SerdeShape

Dataclass for CreateFunctionInput structure.

Attributes

function_code class-attribute instance-attribute
function_code: bytes | None = ...

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

function_config class-attribute instance-attribute
function_config: FunctionConfig | None = ...

Configuration information about the function, including an optional comment and the function's runtime.

name class-attribute instance-attribute
name: str | None = ...

A name to identify the function.

tags class-attribute instance-attribute
tags: Tags | None = ...

A complex type that contains zero or more Tag elements.

Output

CreateFunctionOutput dataclass

Bases: _SerdeShape

Dataclass for CreateFunctionOutput structure.

Attributes

e_tag class-attribute instance-attribute
e_tag: str | None = ...

The version identifier for the current version of the CloudFront function.

function_summary class-attribute instance-attribute
function_summary: FunctionSummary | None = ...

Contains configuration information and metadata about a CloudFront function.

location class-attribute instance-attribute
location: str | None = ...

The URL of the CloudFront function. Use the URL to manage the function with the CloudFront API.

response_metadata class-attribute instance-attribute
response_metadata: ResponseMetadata = ...

Metadata about the response that produced this output. Use this to recover the request identifiers a service's support team needs in order to investigate a call. Members of the metadata are individually optional.