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 | aws.cloudfront.cache_policies |
Fields
Name | Datatype | Description |
---|---|---|
cache_policy_config | object | The cache policy configuration. |
id | string | |
last_modified_time | string | |
region | string | AWS region. |
For more information, see AWS::CloudFront::CachePolicy
.
Methods
Name | Accessible by | Required Params |
---|---|---|
create_resource | INSERT | CachePolicyConfig, 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 cache_policies
in a region.
SELECT
region,
cache_policy_config,
id,
last_modified_time
FROM aws.cloudfront.cache_policies
;
Gets all properties from an individual cache_policy
.
SELECT
region,
cache_policy_config,
id,
last_modified_time
FROM aws.cloudfront.cache_policies
WHERE data__Identifier = '<Id>';
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 aws.cloudfront.cache_policies (
CachePolicyConfig,
region
)
SELECT
'{{ CachePolicyConfig }}',
'{{ region }}';
/*+ create */
INSERT INTO aws.cloudfront.cache_policies (
CachePolicyConfig,
region
)
SELECT
'{{ CachePolicyConfig }}',
'{{ region }}';
version: 1
name: stack name
description: stack description
providers:
- aws
globals:
- name: region
value: '{{ vars.AWS_REGION }}'
resources:
- name: cache_policy
props:
- name: CachePolicyConfig
value:
Comment: '{{ Comment }}'
DefaultTTL: null
MaxTTL: null
MinTTL: null
Name: '{{ Name }}'
ParametersInCacheKeyAndForwardedToOrigin:
CookiesConfig:
CookieBehavior: '{{ CookieBehavior }}'
Cookies:
- '{{ Cookies[0] }}'
EnableAcceptEncodingBrotli: '{{ EnableAcceptEncodingBrotli }}'
EnableAcceptEncodingGzip: '{{ EnableAcceptEncodingGzip }}'
HeadersConfig:
HeaderBehavior: '{{ HeaderBehavior }}'
Headers:
- '{{ Headers[0] }}'
QueryStringsConfig:
QueryStringBehavior: '{{ QueryStringBehavior }}'
QueryStrings:
- '{{ QueryStrings[0] }}'
DELETE
example
/*+ delete */
DELETE FROM aws.cloudfront.cache_policies
WHERE data__Identifier = '<Id>'
AND region = 'us-east-1';
Permissions
To operate on the cache_policies
resource, the following permissions are required:
Create
cloudfront:CreateCachePolicy
Delete
cloudfront:DeleteCachePolicy,
cloudfront:GetCachePolicy
List
cloudfront:ListCachePolicies
Read
cloudfront:GetCachePolicy
Update
cloudfront:UpdateCachePolicy,
cloudfront:GetCachePolicy