cache_policies
Creates, updates, deletes, gets or lists a cache_policies resource.
Overview
| Name | cache_policies |
| Type | Resource |
| Id | aws.cloudfront.cache_policies |
Fields
The following fields are returned by SELECT queries:
- get_cache_policy
- list_cache_policies
| Name | Datatype | Description |
|---|---|---|
cache_policy_config | string | The cache policy configuration. |
id | string | The unique identifier for the cache policy. |
last_modified_time | string | The date and time when the cache policy was last modified. |
| Name | Datatype | Description |
|---|---|---|
items | string | Contains the cache policies in the list. |
max_items | integer | The maximum number of cache policies 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 cache policies where you left off. |
quantity | integer | The total number of cache policies returned in the response. |
Methods
The following methods are available for this resource:
| Name | Accessible by | Required Params | Optional Params | Description |
|---|---|---|---|---|
get_cache_policy | select | id, region | Gets a cache policy, including the following metadata: The policy's identifier. The date and time when the policy was last modified. To get a cache policy, you must provide the policy's identifier. If the cache policy is attached to a distribution's cache behavior, you can get the policy's identifier using ListDistributions or GetDistribution. If the cache policy is not attached to a cache behavior, you can get the identifier using ListCachePolicies. | |
list_cache_policies | select | region | Type, Marker, MaxItems | Gets a list of cache policies. You can optionally apply a filter to return only the managed policies created by Amazon Web Services, or only the custom policies created in your Amazon Web Services account. 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_cache_policy | insert | region, CachePolicyConfig | Creates a cache policy. After you create a cache policy, you can attach it to one or more cache behaviors. 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. If your minimum TTL is greater than 0, CloudFront will cache content for at least the duration specified in the cache policy's minimum TTL, even if the Cache-Control: no-cache, no-store, or private directives are present in the origin headers. 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 an 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. For more information about cache policies, see Controlling the cache key in the Amazon CloudFront Developer Guide. | |
update_cache_policy | update | id, region, CachePolicyConfig | If-Match | Updates a cache policy configuration. When you update a cache policy configuration, all the fields are updated with the values provided in the request. You cannot update some fields independent of others. To update a cache policy configuration: Use GetCachePolicyConfig to get the current configuration. Locally modify the fields in the cache policy configuration that you want to update. Call UpdateCachePolicy by providing the entire cache policy configuration, including the fields that you modified and those that you didn't. If your minimum TTL is greater than 0, CloudFront will cache content for at least the duration specified in the cache policy's minimum TTL, even if the Cache-Control: no-cache, no-store, or private directives are present in the origin headers. |
delete_cache_policy | delete | id, region | If-Match | Deletes a cache policy. You cannot delete a cache policy if it's attached to a cache behavior. First update your distributions to remove the cache policy from all cache behaviors, then delete the cache policy. To delete a cache policy, you must provide the policy's identifier and version. To get these values, you can use ListCachePolicies or GetCachePolicy. |
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 |
|---|---|---|
id | string | The unique identifier for the cache policy that you are deleting. To get the identifier, you can use ListCachePolicies. |
region | string | AWS region (default: us-east-1) |
If-Match | string | The version of the cache policy that you are deleting. The version is the cache policy's ETag value, which you can get using ListCachePolicies, GetCachePolicy, or GetCachePolicyConfig. |
Marker | string | Use this field when paginating results to indicate where to begin in your list of cache policies. The response includes cache policies 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 cache policies that you want in the response. |
Type | string | A filter to return only the specified kinds of cache policies. Valid values are: managed – Returns only the managed policies created by Amazon Web Services. custom – Returns only the custom policies created in your Amazon Web Services account. |
SELECT examples
- get_cache_policy
- list_cache_policies
Gets a cache policy, including the following metadata: The policy's identifier. The date and time when the policy was last modified. To get a cache policy, you must provide the policy's identifier. If the cache policy is attached to a distribution's cache behavior, you can get the policy's identifier using ListDistributions or GetDistribution. If the cache policy is not attached to a cache behavior, you can get the identifier using ListCachePolicies.
SELECT
cache_policy_config,
id,
last_modified_time
FROM aws.cloudfront.cache_policies
WHERE id = '{{ id }}' -- required
AND region = '{{ region }}' -- required
;
Gets a list of cache policies. You can optionally apply a filter to return only the managed policies created by Amazon Web Services, or only the custom policies created in your Amazon Web Services account. 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.cache_policies
WHERE region = '{{ region }}' -- required
AND Type = '{{ Type }}'
AND Marker = '{{ Marker }}'
AND MaxItems = '{{ MaxItems }}'
;
INSERT examples
- create_cache_policy
- Manifest
Creates a cache policy. After you create a cache policy, you can attach it to one or more cache behaviors. 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. If your minimum TTL is greater than 0, CloudFront will cache content for at least the duration specified in the cache policy's minimum TTL, even if the Cache-Control: no-cache, no-store, or private directives are present in the origin headers. 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 an 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. For more information about cache policies, see Controlling the cache key in the Amazon CloudFront Developer Guide.
INSERT INTO aws.cloudfront.cache_policies (
CachePolicyConfig,
region
)
SELECT
'{{ CachePolicyConfig }}' /* required */,
'{{ region }}'
RETURNING
cache_policy_config,
id,
last_modified_time
;
# Description fields are for documentation purposes
- name: cache_policies
props:
- name: region
value: "{{ region }}"
description: Required parameter for the cache_policies resource.
- name: CachePolicyConfig
description: |
A cache policy configuration. This configuration 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. If your minimum TTL is greater than 0, CloudFront will cache content for at least the duration specified in the cache policy's minimum TTL, even if the Cache-Control: no-cache, no-store, or private directives are present in the origin headers. 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.
value:
Comment: "{{ Comment }}"
Name: "{{ Name }}"
DefaultTTL: {{ DefaultTTL }}
MaxTTL: {{ MaxTTL }}
MinTTL: {{ MinTTL }}
ParametersInCacheKeyAndForwardedToOrigin:
EnableAcceptEncodingGzip: {{ EnableAcceptEncodingGzip }}
EnableAcceptEncodingBrotli: {{ EnableAcceptEncodingBrotli }}
HeadersConfig:
HeaderBehavior: "{{ HeaderBehavior }}"
Headers:
Quantity: {{ Quantity }}
Items:
- "{{ Items }}"
CookiesConfig:
CookieBehavior: "{{ CookieBehavior }}"
Cookies:
Quantity: {{ Quantity }}
Items:
- "{{ Items }}"
QueryStringsConfig:
QueryStringBehavior: "{{ QueryStringBehavior }}"
QueryStrings:
Quantity: {{ Quantity }}
Items:
- "{{ Items }}"
UPDATE examples
- update_cache_policy
Updates a cache policy configuration. When you update a cache policy configuration, all the fields are updated with the values provided in the request. You cannot update some fields independent of others. To update a cache policy configuration: Use GetCachePolicyConfig to get the current configuration. Locally modify the fields in the cache policy configuration that you want to update. Call UpdateCachePolicy by providing the entire cache policy configuration, including the fields that you modified and those that you didn't. If your minimum TTL is greater than 0, CloudFront will cache content for at least the duration specified in the cache policy's minimum TTL, even if the Cache-Control: no-cache, no-store, or private directives are present in the origin headers.
UPDATE aws.cloudfront.cache_policies
SET
CachePolicyConfig = '{{ CachePolicyConfig }}'
WHERE
id = '{{ id }}' --required
AND region = '{{ region }}' --required
AND CachePolicyConfig = '{{ CachePolicyConfig }}' --required
AND `If-Match` = '{{ If-Match}}'
RETURNING
cache_policy_config,
id,
last_modified_time;
DELETE examples
- delete_cache_policy
Deletes a cache policy. You cannot delete a cache policy if it's attached to a cache behavior. First update your distributions to remove the cache policy from all cache behaviors, then delete the cache policy. To delete a cache policy, you must provide the policy's identifier and version. To get these values, you can use ListCachePolicies or GetCachePolicy.
DELETE FROM aws.cloudfront.cache_policies
WHERE id = '{{ id }}' --required
AND region = '{{ region }}' --required
AND `If-Match` = '{{ If-Match }}'
;