cache_policies
Creates, updates, deletes or gets a cache_policy resource or lists cache_policies in a region
Overview
| Name | cache_policies |
| Type | Resource |
| Description | A cache policy. When it's attached to a cache behavior, the cache policy determines the following: + The values that CloudFront includes in the cache key. These values can include HTTP headers, cookies, and URL query strings. CloudFront uses the cache key to find an object in its cache that it can return to the viewer. + The default, minimum, and maximum time to live (TTL) values that you want objects to stay in the CloudFront cache. The headers, cookies, and query strings that are included in the cache key are also included in requests that CloudFront sends to the origin. CloudFront sends a request when it can't find a valid object in its cache that matches the request's cache key. If you want to send values to the origin but *not* include them in the cache key, use ``OriginRequestPolicy``. |
| Id | awscc.cloudfront.cache_policies |
Fields
- get (all properties)
- list (identifiers only)
| Name | Datatype | Description |
|---|---|---|
cache_policy_config | object | The cache policy configuration. |
id | string | |
last_modified_time | string | |
region | string | AWS region. |
| Name | Datatype | Description |
|---|---|---|
id | string | |
region | string | AWS region. |
For more information, see AWS::CloudFront::CachePolicy.
Methods
| Name | Resource | Accessible by | Required Params |
|---|---|---|---|
create_resource | cache_policies | INSERT | CachePolicyConfig, region |
delete_resource | cache_policies | DELETE | Identifier, region |
update_resource | cache_policies | UPDATE | Identifier, PatchDocument, region |
list_resources | cache_policies_list_only | SELECT | region |
get_resource | cache_policies | SELECT | Identifier, region |
SELECT examples
- get (all properties)
- list (identifiers only)
Gets all properties from an individual cache_policy.
SELECT
region,
cache_policy_config,
id,
last_modified_time
FROM awscc.cloudfront.cache_policies
WHERE
region = 'us-east-1' AND
Identifier = '{{ id }}';
Lists all cache_policies in a region.
SELECT
region,
id
FROM awscc.cloudfront.cache_policies_list_only
WHERE
region = 'us-east-1';
INSERT example
Use the following StackQL query and manifest file to create a new cache_policy resource, using stack-deploy.
- Required Properties
- All Properties
- Manifest
/*+ create */
INSERT INTO awscc.cloudfront.cache_policies (
CachePolicyConfig,
region
)
SELECT
'{{ cache_policy_config }}',
'{{ region }}';
/*+ create */
INSERT INTO awscc.cloudfront.cache_policies (
CachePolicyConfig,
region
)
SELECT
'{{ cache_policy_config }}',
'{{ region }}';
version: 1
name: stack name
description: stack description
providers:
- aws
globals:
- name: region
value: '{{ vars.AWS_REGION }}'
resources:
- name: cache_policy
props:
- name: cache_policy_config
value:
comment: '{{ comment }}'
default_ttl: null
max_ttl: null
min_ttl: null
name: '{{ name }}'
parameters_in_cache_key_and_forwarded_to_origin:
cookies_config:
cookie_behavior: '{{ cookie_behavior }}'
cookies:
- '{{ cookies[0] }}'
enable_accept_encoding_brotli: '{{ enable_accept_encoding_brotli }}'
enable_accept_encoding_gzip: '{{ enable_accept_encoding_gzip }}'
headers_config:
header_behavior: '{{ header_behavior }}'
headers:
- '{{ headers[0] }}'
query_strings_config:
query_string_behavior: '{{ query_string_behavior }}'
query_strings:
- '{{ query_strings[0] }}'
UPDATE example
Use the following StackQL query and manifest file to update a cache_policy resource, using stack-deploy.
/*+ update */
UPDATE awscc.cloudfront.cache_policies
SET PatchDocument = string('{{ {
"CachePolicyConfig": cache_policy_config
} | generate_patch_document }}')
WHERE
region = '{{ region }}' AND
Identifier = '{{ id }}';
DELETE example
/*+ delete */
DELETE FROM awscc.cloudfront.cache_policies
WHERE
Identifier = '{{ id }}' AND
region = 'us-east-1';
Permissions
To operate on the cache_policies resource, the following permissions are required:
- Create
- Delete
- List
- Read
- Update
cloudfront:CreateCachePolicy
cloudfront:DeleteCachePolicy,
cloudfront:GetCachePolicy
cloudfront:ListCachePolicies
cloudfront:GetCachePolicy
cloudfront:UpdateCachePolicy,
cloudfront:GetCachePolicy