From 096e3555c9110df5a2ea0d835a9ab8f88178e567 Mon Sep 17 00:00:00 2001 From: "Philippe M. Chiasson" Date: Wed, 21 Apr 2021 11:26:53 -0400 Subject: [PATCH] Add support for query_string_cache_keys (#157) * Add support for query_string_cache_keys Fixes #156 Co-authored-by: cloudpossebot <11232728+cloudpossebot@users.noreply.github.com> --- README.md | 4 ++-- docs/terraform.md | 1 + main.tf | 5 +++-- variables.tf | 6 ++++++ 4 files changed, 12 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 80c879c3..5c2f1589 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,4 @@ + # terraform-aws-cloudfront-s3-cdn [![Codefresh Build Status](https://g.codefresh.io/api/badges/pipeline/cloudposse/terraform-modules%2Fterraform-aws-cloudfront-s3-cdn?type=cf-1)](https://g.codefresh.io/public/accounts/cloudposse/pipelines/5d169121757962ff25679794) [![Latest Release](https://img.shields.io/github/release/cloudposse/terraform-aws-cloudfront-s3-cdn.svg)](https://travis-ci.org/cloudposse/terraform-aws-cloudfront-s3-cdn/releases) [![Slack Community](https://slack.cloudposse.com/badge.svg)](https://slack.cloudposse.com) @@ -29,7 +30,6 @@ Terraform module to provision an AWS CloudFront CDN with an S3 origin. - --- This project is part of our comprehensive ["SweetOps"](https://cpco.io/sweetops) approach towards DevOps. @@ -60,7 +60,6 @@ We literally have [*hundreds of terraform modules*][terraform_modules] that are - ## Security & Compliance [](https://bridgecrew.io/) Security scanning is graciously provided by Bridgecrew. Bridgecrew is the leading fully hosted, cloud-native solution providing continuous Terraform security and compliance. @@ -318,6 +317,7 @@ Available targets: | [parent\_zone\_id](#input\_parent\_zone\_id) | ID of the hosted zone to contain this record (or specify `parent_zone_name`). Requires `dns_alias_enabled` set to true | `string` | `""` | no | | [parent\_zone\_name](#input\_parent\_zone\_name) | Name of the hosted zone to contain this record (or specify `parent_zone_id`). Requires `dns_alias_enabled` set to true | `string` | `""` | no | | [price\_class](#input\_price\_class) | Price class for this distribution: `PriceClass_All`, `PriceClass_200`, `PriceClass_100` | `string` | `"PriceClass_100"` | no | +| [query\_string\_cache\_keys](#input\_query\_string\_cache\_keys) | When Forward query strings is enabled, only the query string keys listed in this argument are cached | `list(string)` | `[]` | no | | [redirect\_all\_requests\_to](#input\_redirect\_all\_requests\_to) | A hostname to redirect all website requests for this distribution to. If this is set, it overrides other website settings | `string` | `""` | no | | [regex\_replace\_chars](#input\_regex\_replace\_chars) | Regex to replace chars with empty string in `namespace`, `environment`, `stage` and `name`.
If not set, `"/[^a-zA-Z0-9-]/"` is used to remove all characters other than hyphens, letters and digits. | `string` | `null` | no | | [routing\_rules](#input\_routing\_rules) | A json array containing routing rules describing redirect behavior and when redirects are applied | `string` | `""` | no | diff --git a/docs/terraform.md b/docs/terraform.md index 95a50dcc..802abe84 100644 --- a/docs/terraform.md +++ b/docs/terraform.md @@ -104,6 +104,7 @@ | [parent\_zone\_id](#input\_parent\_zone\_id) | ID of the hosted zone to contain this record (or specify `parent_zone_name`). Requires `dns_alias_enabled` set to true | `string` | `""` | no | | [parent\_zone\_name](#input\_parent\_zone\_name) | Name of the hosted zone to contain this record (or specify `parent_zone_id`). Requires `dns_alias_enabled` set to true | `string` | `""` | no | | [price\_class](#input\_price\_class) | Price class for this distribution: `PriceClass_All`, `PriceClass_200`, `PriceClass_100` | `string` | `"PriceClass_100"` | no | +| [query\_string\_cache\_keys](#input\_query\_string\_cache\_keys) | When Forward query strings is enabled, only the query string keys listed in this argument are cached | `list(string)` | `[]` | no | | [redirect\_all\_requests\_to](#input\_redirect\_all\_requests\_to) | A hostname to redirect all website requests for this distribution to. If this is set, it overrides other website settings | `string` | `""` | no | | [regex\_replace\_chars](#input\_regex\_replace\_chars) | Regex to replace chars with empty string in `namespace`, `environment`, `stage` and `name`.
If not set, `"/[^a-zA-Z0-9-]/"` is used to remove all characters other than hyphens, letters and digits. | `string` | `null` | no | | [routing\_rules](#input\_routing\_rules) | A json array containing routing rules describing redirect behavior and when redirects are applied | `string` | `""` | no | diff --git a/main.tf b/main.tf index 9e8d69eb..304757ee 100644 --- a/main.tf +++ b/main.tf @@ -282,8 +282,9 @@ resource "aws_cloudfront_distribution" "default" { trusted_signers = var.trusted_signers forwarded_values { - query_string = var.forward_query_string - headers = var.forward_header_values + query_string = var.forward_query_string + query_string_cache_keys = var.query_string_cache_keys + headers = var.forward_header_values cookies { forward = var.forward_cookies diff --git a/variables.tf b/variables.tf index 3e17eee9..76296d91 100644 --- a/variables.tf +++ b/variables.tf @@ -125,6 +125,12 @@ variable "forward_query_string" { description = "Forward query strings to the origin that is associated with this cache behavior" } +variable "query_string_cache_keys" { + type = list(string) + description = "When Forward query strings is enabled, only the query string keys listed in this argument are cached" + default = [] +} + variable "cors_allowed_headers" { type = list(string) default = ["*"]