functions
Creates, updates, deletes or gets a function
resource or lists functions
in a region
Overview
Name | functions |
Type | Resource |
Description | 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 . |
Id | aws.cloudfront.functions |
Fields
Name | Datatype | Description |
---|---|---|
auto_publish | boolean | A flag that determines whether to automatically publish the function to the LIVE stage when it’s created. To automatically publish to the LIVE stage, set this property to true . |
function_arn | string | |
function_code | string | The function code. For more information about writing a CloudFront function, see [Writing function code for CloudFront Functions](https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/writing-function-code.html) in the *Amazon CloudFront Developer Guide*. |
function_config | object | Contains configuration information about a CloudFront function. |
function_metadata | object | Contains metadata about a CloudFront function. |
name | string | A name to identify the function. |
stage | string | |
region | string | AWS region. |
For more information, see AWS::CloudFront::Function
.
Methods
Name | Accessible by | Required Params |
---|---|---|
create_resource | INSERT | Name, FunctionConfig, FunctionCode, region |
delete_resource | DELETE | data__Identifier, region |
update_resource | UPDATE | data__Identifier, data__PatchDocument, region |
list_resources | SELECT | region |
get_resource | SELECT | data__Identifier, region |
SELECT
examples
Gets all functions
in a region.
SELECT
region,
auto_publish,
function_arn,
function_code,
function_config,
function_metadata,
name,
stage
FROM aws.cloudfront.functions
;
Gets all properties from an individual function
.
SELECT
region,
auto_publish,
function_arn,
function_code,
function_config,
function_metadata,
name,
stage
FROM aws.cloudfront.functions
WHERE data__Identifier = '<FunctionARN>';
INSERT
example
Use the following StackQL query and manifest file to create a new function
resource, using stack-deploy
.
- Required Properties
- All Properties
- Manifest
/*+ create */
INSERT INTO aws.cloudfront.functions (
FunctionCode,
FunctionConfig,
Name,
region
)
SELECT
'{{ FunctionCode }}',
'{{ FunctionConfig }}',
'{{ Name }}',
'{{ region }}';
/*+ create */
INSERT INTO aws.cloudfront.functions (
AutoPublish,
FunctionCode,
FunctionConfig,
FunctionMetadata,
Name,
region
)
SELECT
'{{ AutoPublish }}',
'{{ FunctionCode }}',
'{{ FunctionConfig }}',
'{{ FunctionMetadata }}',
'{{ Name }}',
'{{ region }}';
version: 1
name: stack name
description: stack description
providers:
- aws
globals:
- name: region
value: '{{ vars.AWS_REGION }}'
resources:
- name: function
props:
- name: AutoPublish
value: '{{ AutoPublish }}'
- name: FunctionCode
value: '{{ FunctionCode }}'
- name: FunctionConfig
value:
Comment: '{{ Comment }}'
Runtime: '{{ Runtime }}'
KeyValueStoreAssociations:
- KeyValueStoreARN: '{{ KeyValueStoreARN }}'
- name: FunctionMetadata
value:
FunctionARN: '{{ FunctionARN }}'
- name: Name
value: '{{ Name }}'
DELETE
example
/*+ delete */
DELETE FROM aws.cloudfront.functions
WHERE data__Identifier = '<FunctionARN>'
AND region = 'us-east-1';
Permissions
To operate on the functions
resource, the following permissions are required:
Create
cloudfront:CreateFunction,
cloudfront:PublishFunction,
cloudfront:DescribeFunction
Delete
cloudfront:DeleteFunction,
cloudfront:DescribeFunction
List
cloudfront:ListFunctions
Read
cloudfront:DescribeFunction,
cloudfront:GetFunction
Update
cloudfront:UpdateFunction,
cloudfront:PublishFunction,
cloudfront:DescribeFunction