Skip to content

Data source: awsCloudfrontCachePolicy

Use this data source to retrieve information about a CloudFront cache policy.

Example Usage

Basic Usage

/*Provider bindings are generated by running cdktf get.
See https://cdk.tf/provider-generation for more details.*/
import * as aws from "./.gen/providers/aws";
new aws.dataAwsCloudfrontCachePolicy.DataAwsCloudfrontCachePolicy(
  this,
  "example",
  {
    name: "example-policy",
  }
);

AWS-Managed Policies

AWS managed cache policy names are prefixed with managed:

/*Provider bindings are generated by running cdktf get.
See https://cdk.tf/provider-generation for more details.*/
import * as aws from "./.gen/providers/aws";
new aws.dataAwsCloudfrontCachePolicy.DataAwsCloudfrontCachePolicy(
  this,
  "example",
  {
    name: "Managed-CachingOptimized",
  }
);

Argument Reference

The following arguments are supported:

  • name - (Optional) Unique name to identify the cache policy.
  • id - (Optional) Identifier for the cache policy.

Attributes Reference

In addition to all arguments above, the following attributes are exported:

  • etag - Current version of the cache policy.
  • minTtl - Minimum amount of time, in seconds, that you want objects to stay in the CloudFront cache before CloudFront sends another request to the origin to see if the object has been updated.
  • maxTtl - Maximum amount of time, in seconds, that objects stay in the CloudFront cache before CloudFront sends another request to the origin to see if the object has been updated.
  • defaultTtl - Default amount of time, in seconds, that you want objects to stay in the CloudFront cache before CloudFront sends another request to the origin to see if the object has been updated.
  • comment - Comment to describe the cache policy.
  • parametersInCacheKeyAndForwardedToOrigin - The HTTP headers, cookies, and URL query strings to include in the cache key. See Parameters In Cache Key And Forwarded To Origin for more information.

Parameters In Cache Key And Forwarded To Origin

  • cookiesConfig - Object that determines whether any cookies in viewer requests (and if so, which cookies) are included in the cache key and automatically included in requests that CloudFront sends to the origin. See Cookies Config for more information.
  • headersConfig - Object that determines whether any HTTP headers (and if so, which headers) are included in the cache key and automatically included in requests that CloudFront sends to the origin. See Headers Config for more information.
  • queryStringsConfig - Object that determines whether any URL query strings in viewer requests (and if so, which query strings) are included in the cache key and automatically included in requests that CloudFront sends to the origin. See Query String Config for more information.
  • enableAcceptEncodingBrotli - A flag that can affect whether the Accept-Encoding HTTP header is included in the cache key and included in requests that CloudFront sends to the origin.
  • enableAcceptEncodingGzip - A flag that can affect whether the Accept-Encoding HTTP header is included in the cache key and included in requests that CloudFront sends to the origin.

Cookies Config

  • cookieBehavior - Determines whether any cookies in viewer requests are included in the cache key and automatically included in requests that CloudFront sends to the origin. Valid values are none, whitelist, allExcept, all.
  • cookies - Object that contains a list of cookie names. See Items for more information.

Headers Config

  • headerBehavior - Determines whether any HTTP headers are included in the cache key and automatically included in requests that CloudFront sends to the origin. Valid values are none, whitelist.
  • headers - Object that contains a list of header names. See Items for more information.

Query String Config

  • queryStringBehavior - Determines whether any URL query strings in viewer requests are included in the cache key and automatically included in requests that CloudFront sends to the origin. Valid values are none, whitelist, allExcept, all.
  • queryStrings - Object that contains a list of query string names. See Items for more information.

Items

  • items - List of item names (cookies, headers, or queryStrings).