Skip to content

Resource: awsCloudfrontOriginRequestPolicy

Example Usage

The following example below creates a CloudFront origin request policy.

/*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.cloudfrontOriginRequestPolicy.CloudfrontOriginRequestPolicy(
  this,
  "example",
  {
    comment: "example comment",
    cookiesConfig: {
      cookieBehavior: "whitelist",
      cookies: {
        items: ["example"],
      },
    },
    headersConfig: {
      headerBehavior: "whitelist",
      headers: {
        items: ["example"],
      },
    },
    name: "example-policy",
    queryStringsConfig: {
      queryStringBehavior: "whitelist",
      queryStrings: {
        items: ["example"],
      },
    },
  }
);

Argument Reference

The following arguments are supported:

  • name - (Required) Unique name to identify the origin request policy.
  • comment - (Optional) Comment to describe the origin request policy.
  • cookiesConfig - (Required) Object that determines whether any cookies in viewer requests (and if so, which cookies) are included in the origin request key and automatically included in requests that CloudFront sends to the origin. See Cookies Config for more information.
  • headersConfig - (Required) Object that determines whether any HTTP headers (and if so, which headers) are included in the origin request key and automatically included in requests that CloudFront sends to the origin. See Headers Config for more information.
  • queryStringsConfig - (Required) Object that determines whether any URL query strings in viewer requests (and if so, which query strings) are included in the origin request key and automatically included in requests that CloudFront sends to the origin. See Query String Config for more information.

Cookies Config

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

Headers Config

headerBehavior - (Required) Determines whether any HTTP headers are included in the origin request key and automatically included in requests that CloudFront sends to the origin. Valid values are none, whitelist, allViewer, allViewerAndWhitelistCloudFront, allExcept. headers - (Optional) Object that contains a list of header names. See Items for more information.

Query String Config

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

Items

items - (Required) List of item names (cookies, headers, or query strings).

Attributes Reference

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

  • etag - The current version of the origin request policy.
  • id - The identifier for the origin request policy.

Import

Cloudfront Origin Request Policies can be imported using the id, e.g.

$ terraform import aws_cloudfront_origin_request_policy.policy ccca32ef-dce3-4df3-80df-1bd3000bc4d3