Skip to main content

functions

Creates, updates, deletes, gets or lists a functions resource.

Overview

Namefunctions
TypeResource
Idaws.cloudfront.functions

Fields

The following fields are returned by SELECT queries:

NameDatatypeDescription
content_typestringThe content type (media type) of the response.
e_tagstringThe version identifier for the current version of the CloudFront function.
function_codestringThe function code of a CloudFront function.

Methods

The following methods are available for this resource:

NameAccessible byRequired ParamsOptional ParamsDescription
get_functionselectname, regionStageGets the code of a CloudFront function. To get configuration information and metadata about a function, use DescribeFunction. To get a function's code, you must provide the function's name and stage. To get these values, you can use ListFunctions.
list_functionsselectregionMarker, MaxItems, StageGets a list of all CloudFront functions in your Amazon Web Services account. You can optionally apply a filter to return only the functions that are in the specified stage, either DEVELOPMENT or LIVE. You can optionally specify the maximum number of items to receive in the response. If the total number of items in the list exceeds the maximum that you specify, or the default maximum, the response is paginated. To get the next page of items, send a subsequent request that specifies the NextMarker value from the current response as the Marker value in the subsequent request.
create_functioninsertregion, FunctionConfig, FunctionCodeCreates 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.
update_functionupdatename, If-Match, region, FunctionConfig, FunctionCodeUpdates a CloudFront function. You can update a function's code or the comment that describes the function. You cannot update a function's name. To update a function, you provide the function's name and version (ETag value) along with the updated function code. To get the name and version, you can use ListFunctions and DescribeFunction.
delete_functiondeletename, If-Match, regionDeletes a CloudFront function. You cannot delete a function if it's associated with a cache behavior. First, update your distributions to remove the function association from all cache behaviors, then delete the function. To delete a function, you must provide the function's name and version (ETag value). To get these values, you can use ListFunctions and DescribeFunction.
describe_functionexecname, regionStageGets configuration information and metadata about a CloudFront function, but not the function's code. To get a function's code, use GetFunction. To get configuration information and metadata about a function, you must provide the function's name and stage. To get these values, you can use ListFunctions.

Parameters

Parameters can be passed in the WHERE clause of a query. Check the Methods section to see which parameters are required or optional for each operation.

NameDatatypeDescription
If-MatchstringThe current version (ETag value) of the function that you are deleting, which you can get using DescribeFunction.
namestringThe name of the function that you are getting information about.
regionstringAWS region (default: us-east-1)
MarkerstringUse this field when paginating results to indicate where to begin in your list of functions. The response includes functions in the list that occur after the marker. To get the next page of the list, set this field's value to the value of NextMarker from the current page's response.
MaxItemsstringThe maximum number of functions that you want in the response.
StagestringThe function's stage, either DEVELOPMENT or LIVE.

SELECT examples

Gets the code of a CloudFront function. To get configuration information and metadata about a function, use DescribeFunction. To get a function's code, you must provide the function's name and stage. To get these values, you can use ListFunctions.

SELECT
content_type,
e_tag,
function_code
FROM aws.cloudfront.functions
WHERE name = '{{ name }}' -- required
AND region = '{{ region }}' -- required
AND Stage = '{{ Stage }}'
;

INSERT examples

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.

INSERT INTO aws.cloudfront.functions (
Name,
FunctionConfig,
FunctionCode,
Tags,
region
)
SELECT
'{{ Name }}',
'{{ FunctionConfig }}' /* required */,
'{{ FunctionCode }}' /* required */,
'{{ Tags }}',
'{{ region }}'
RETURNING
e_tag,
function_summary,
location
;

UPDATE examples

Updates a CloudFront function. You can update a function's code or the comment that describes the function. You cannot update a function's name. To update a function, you provide the function's name and version (ETag value) along with the updated function code. To get the name and version, you can use ListFunctions and DescribeFunction.

UPDATE aws.cloudfront.functions
SET
FunctionConfig = '{{ FunctionConfig }}',
FunctionCode = '{{ FunctionCode }}'
WHERE
name = '{{ name }}' --required
AND `If-Match` = '{{ If-Match }}' --required
AND region = '{{ region }}' --required
AND FunctionConfig = '{{ FunctionConfig }}' --required
AND FunctionCode = '{{ FunctionCode }}' --required
RETURNING
e_tag,
function_summary;

DELETE examples

Deletes a CloudFront function. You cannot delete a function if it's associated with a cache behavior. First, update your distributions to remove the function association from all cache behaviors, then delete the function. To delete a function, you must provide the function's name and version (ETag value). To get these values, you can use ListFunctions and DescribeFunction.

DELETE FROM aws.cloudfront.functions
WHERE name = '{{ name }}' --required
AND `If-Match` = '{{ If-Match }}' --required
AND region = '{{ region }}' --required
;

Lifecycle Methods

Gets configuration information and metadata about a CloudFront function, but not the function's code. To get a function's code, use GetFunction. To get configuration information and metadata about a function, you must provide the function's name and stage. To get these values, you can use ListFunctions.

EXEC aws.cloudfront.functions.describe_function
@name='{{ name }}' --required,
@region='{{ region }}' --required,
@Stage='{{ Stage }}'
;