Skip to main content

cache_policies

Creates, updates, deletes or gets a cache_policy resource or lists cache_policies in a region

Overview

Namecache_policies
TypeResource
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.
Idawscc.cloudfront.cache_policies

Fields

NameDatatypeDescription
cache_policy_configobjectThe cache policy configuration.
idstring
last_modified_timestring
regionstringAWS region.

For more information, see AWS::CloudFront::CachePolicy.

Methods

NameResourceAccessible byRequired Params
create_resourcecache_policiesINSERTCachePolicyConfig, region
delete_resourcecache_policiesDELETEIdentifier, region
update_resourcecache_policiesUPDATEIdentifier, PatchDocument, region
list_resourcescache_policies_list_onlySELECTregion
get_resourcecache_policiesSELECTIdentifier, region

SELECT examples

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 }}';

INSERT example

Use the following StackQL query and manifest file to create a new cache_policy resource, using stack-deploy.

/*+ create */
INSERT INTO awscc.cloudfront.cache_policies (
CachePolicyConfig,
region
)
SELECT
'{{ cache_policy_config }}',
'{{ region }}'
RETURNING
ErrorCode,
EventTime,
Identifier,
Operation,
OperationStatus,
RequestToken,
ResourceModel,
RetryAfter,
StatusMessage,
TypeName
;

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 }}'
RETURNING
ErrorCode,
EventTime,
Identifier,
Operation,
OperationStatus,
RequestToken,
ResourceModel,
RetryAfter,
StatusMessage,
TypeName
;

DELETE example

/*+ delete */
DELETE FROM awscc.cloudfront.cache_policies
WHERE
Identifier = '{{ id }}' AND
region = 'us-east-1'
RETURNING
ErrorCode,
EventTime,
Identifier,
Operation,
OperationStatus,
RequestToken,
ResourceModel,
RetryAfter,
StatusMessage,
TypeName
;

Additional Parameters

Mutable resources in the Cloud Control provider support additional optional parameters which can be supplied with INSERT, UPDATE, or DELETE operations. These include:

ParameterDescription
ClientToken
A unique identifier to ensure the idempotency of the resource request.This allows the provider to accurately distinguish between retries and new requests.
A client token is valid for 36 hours once used.
After that, a resource request with the same client token is treated as a new request.
If you do not specify a client token, one is generated for inclusion in the request.
RoleArn
The ARN of the IAM role used to perform this resource operation.The role specified must have the permissions required for this operation.
If you do not specify a role, a temporary session is created using your AWS user credentials.
TypeVersionId
For private resource types, the type version to use in this resource operation.If you do not specify a resource version, the default version is used.

Permissions

To operate on the cache_policies resource, the following permissions are required:

cloudfront:CreateCachePolicy