Skip to content

Commit

Permalink
feat: dynamic forwarded values
Browse files Browse the repository at this point in the history
Set forwarded values to dynamic block to make it optional
  • Loading branch information
coolapso committed Jul 2, 2024
1 parent 567dd0e commit 7cefd94
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 4 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ No modules.
| <a name="input_s3_origin_id"></a> [s3\_origin\_id](#input\_s3\_origin\_id) | unique origin id | `string` | `"s3Website"` | no |
| <a name="input_s3_origin_path"></a> [s3\_origin\_path](#input\_s3\_origin\_path) | objects origin path if using subfolders | `string` | `null` | no |
| <a name="input_s3_regional_domain_name"></a> [s3\_regional\_domain\_name](#input\_s3\_regional\_domain\_name) | The regional domain name of the bucket | `string` | n/a | yes |
| <a name="input_set_forwarded_values"></a> [set\_forwarded\_values](#input\_set\_forwarded\_values) | enables / disables cache behavior forwarded values | `bool` | `true` | no |
| <a name="input_ssl_support_method"></a> [ssl\_support\_method](#input\_ssl\_support\_method) | SSL support method to be used | `string` | `"sni-only"` | no |
| <a name="input_tls_minimum_protocol_version"></a> [tls\_minimum\_protocol\_version](#input\_tls\_minimum\_protocol\_version) | Minimum TLS version | `string` | `"TLSv1.2_2021"` | no |
| <a name="input_viewer_protocol_policy"></a> [viewer\_protocol\_policy](#input\_viewer\_protocol\_policy) | specify the protocol that users can use to access the files in the origin | `string` | `"redirect-to-https"` | no |
Expand Down
12 changes: 8 additions & 4 deletions main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -57,11 +57,15 @@ resource "aws_cloudfront_distribution" "this" {
cached_methods = ["GET", "HEAD"]
target_origin_id = var.s3_origin_id

forwarded_values {
query_string = var.forward_query_strings
dynamic "forwarded_values" {
for_each = var.set_forwarded_values ? { "key" = 1 } : {}

cookies {
forward = var.cookies_forward
content {
query_string = var.forward_query_strings

cookies {
forward = var.cookies_forward
}
}
}

Expand Down
6 changes: 6 additions & 0 deletions variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,12 @@ variable "price_class" {
default = "PriceClass_All"
}

variable "set_forwarded_values" {
description = "enables / disables cache behavior forwarded values"
type = bool
default = true
}

variable "forward_query_strings" {
description = "Enables/disables query string forwarding"
type = bool
Expand Down

0 comments on commit 7cefd94

Please sign in to comment.