functions
Creates, updates, deletes, gets or lists a functions resource.
Overview
| Name | functions |
| Type | Resource |
| Id | aws.cloudfront.functions |
Fields
The following fields are returned by SELECT queries:
- get_function
- list_functions
| Name | Datatype | Description |
|---|---|---|
content_type | string | The content type (media type) of the response. |
e_tag | string | The version identifier for the current version of the CloudFront function. |
function_code | string | The function code of a CloudFront function. |
| Name | Datatype | Description |
|---|---|---|
items | string | Contains the functions in the list. |
max_items | integer | The maximum number of functions requested. |
next_marker | string | If there are more items in the list than are in this response, this element is present. It contains the value that you should use in the Marker field of a subsequent request to continue listing functions where you left off. |
quantity | integer | The number of functions returned in the response. |
Methods
The following methods are available for this resource:
| Name | Accessible by | Required Params | Optional Params | Description |
|---|---|---|---|---|
get_function | select | name, region | Stage | 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. |
list_functions | select | region | Marker, MaxItems, Stage | Gets 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_function | insert | region, FunctionConfig, FunctionCode | 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. | |
update_function | update | name, If-Match, region, FunctionConfig, FunctionCode | 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. | |
delete_function | delete | name, If-Match, region | 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. | |
describe_function | exec | name, region | Stage | 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. |
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.
| Name | Datatype | Description |
|---|---|---|
If-Match | string | The current version (ETag value) of the function that you are deleting, which you can get using DescribeFunction. |
name | string | The name of the function that you are getting information about. |
region | string | AWS region (default: us-east-1) |
Marker | string | Use 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. |
MaxItems | string | The maximum number of functions that you want in the response. |
Stage | string | The function's stage, either DEVELOPMENT or LIVE. |
SELECT examples
- get_function
- list_functions
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 }}'
;
Gets 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.
SELECT
items,
max_items,
next_marker,
quantity
FROM aws.cloudfront.functions
WHERE region = '{{ region }}' -- required
AND Marker = '{{ Marker }}'
AND MaxItems = '{{ MaxItems }}'
AND Stage = '{{ Stage }}'
;
INSERT examples
- create_function
- Manifest
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
;
# Description fields are for documentation purposes
- name: functions
props:
- name: region
value: "{{ region }}"
description: Required parameter for the functions resource.
- name: Name
value: "{{ Name }}"
- name: FunctionConfig
description: |
Contains configuration information about a CloudFront function.
value:
Comment: "{{ Comment }}"
Runtime: "{{ Runtime }}"
KeyValueStoreAssociations:
Quantity: {{ Quantity }}
Items:
- KeyValueStoreARN: "{{ KeyValueStoreARN }}"
- name: FunctionCode
value: "{{ FunctionCode }}"
- name: Tags
description: |
A complex type that contains zero or more Tag elements.
value:
Items:
- Key: "{{ Key }}"
Value: "{{ Value }}"
UPDATE examples
- update_function
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
- delete_function
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
- describe_function
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 }}'
;