Skip to content

Commit 3f39c57

Browse files
itschrishudsoncloudpossebotnitrocode
authored
Add response headers policy input for CloudFront distributions default behaviour (#195)
* Add response_headers_policy_id Co-authored-by: cloudpossebot <[email protected]> Co-authored-by: nitrocode <[email protected]>
1 parent 47d70f2 commit 3f39c57

File tree

4 files changed

+16
-7
lines changed

4 files changed

+16
-7
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -489,6 +489,7 @@ Available targets:
489489
| <a name="input_realtime_log_config_arn"></a> [realtime\_log\_config\_arn](#input\_realtime\_log\_config\_arn) | The ARN of the real-time log configuration that is attached to this cache behavior | `string` | `null` | no |
490490
| <a name="input_redirect_all_requests_to"></a> [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 |
491491
| <a name="input_regex_replace_chars"></a> [regex\_replace\_chars](#input\_regex\_replace\_chars) | Terraform regular expression (regex) string.<br>Characters matching the regex will be removed from the ID elements.<br>If not set, `"/[^a-zA-Z0-9-]/"` is used to remove all characters other than hyphens, letters and digits. | `string` | `null` | no |
492+
| <a name="input_response_headers_policy_id"></a> [response\_headers\_policy\_id](#input\_response\_headers\_policy\_id) | The identifier for a response headers policy | `string` | `""` | no |
492493
| <a name="input_routing_rules"></a> [routing\_rules](#input\_routing\_rules) | A json array containing routing rules describing redirect behavior and when redirects are applied | `string` | `""` | no |
493494
| <a name="input_s3_access_log_bucket_name"></a> [s3\_access\_log\_bucket\_name](#input\_s3\_access\_log\_bucket\_name) | Name of the existing S3 bucket where S3 Access Logs will be delivered. Default is not to enable S3 Access Logging. | `string` | `""` | no |
494495
| <a name="input_s3_access_log_prefix"></a> [s3\_access\_log\_prefix](#input\_s3\_access\_log\_prefix) | Prefix to use for S3 Access Log object keys. Defaults to `logs/${module.this.id}` | `string` | `""` | no |

docs/terraform.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,7 @@
128128
| <a name="input_realtime_log_config_arn"></a> [realtime\_log\_config\_arn](#input\_realtime\_log\_config\_arn) | The ARN of the real-time log configuration that is attached to this cache behavior | `string` | `null` | no |
129129
| <a name="input_redirect_all_requests_to"></a> [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 |
130130
| <a name="input_regex_replace_chars"></a> [regex\_replace\_chars](#input\_regex\_replace\_chars) | Terraform regular expression (regex) string.<br>Characters matching the regex will be removed from the ID elements.<br>If not set, `"/[^a-zA-Z0-9-]/"` is used to remove all characters other than hyphens, letters and digits. | `string` | `null` | no |
131+
| <a name="input_response_headers_policy_id"></a> [response\_headers\_policy\_id](#input\_response\_headers\_policy\_id) | The identifier for a response headers policy | `string` | `""` | no |
131132
| <a name="input_routing_rules"></a> [routing\_rules](#input\_routing\_rules) | A json array containing routing rules describing redirect behavior and when redirects are applied | `string` | `""` | no |
132133
| <a name="input_s3_access_log_bucket_name"></a> [s3\_access\_log\_bucket\_name](#input\_s3\_access\_log\_bucket\_name) | Name of the existing S3 bucket where S3 Access Logs will be delivered. Default is not to enable S3 Access Logging. | `string` | `""` | no |
133134
| <a name="input_s3_access_log_prefix"></a> [s3\_access\_log\_prefix](#input\_s3\_access\_log\_prefix) | Prefix to use for S3 Access Log object keys. Defaults to `logs/${module.this.id}` | `string` | `""` | no |

main.tf

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -437,13 +437,14 @@ resource "aws_cloudfront_distribution" "default" {
437437
}
438438

439439
default_cache_behavior {
440-
allowed_methods = var.allowed_methods
441-
cached_methods = var.cached_methods
442-
cache_policy_id = var.cache_policy_id
443-
target_origin_id = local.origin_id
444-
compress = var.compress
445-
trusted_signers = var.trusted_signers
446-
trusted_key_groups = var.trusted_key_groups
440+
allowed_methods = var.allowed_methods
441+
cached_methods = var.cached_methods
442+
cache_policy_id = var.cache_policy_id
443+
target_origin_id = local.origin_id
444+
compress = var.compress
445+
trusted_signers = var.trusted_signers
446+
trusted_key_groups = var.trusted_key_groups
447+
response_headers_policy_id = var.response_headers_policy_id
447448

448449
dynamic "forwarded_values" {
449450
# If a cache policy is specified, we cannot include a `forwarded_values` block at all in the API request

variables.tf

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,12 @@ variable "price_class" {
175175
description = "Price class for this distribution: `PriceClass_All`, `PriceClass_200`, `PriceClass_100`"
176176
}
177177

178+
variable "response_headers_policy_id" {
179+
type = string
180+
description = "The identifier for a response headers policy"
181+
default = ""
182+
}
183+
178184
variable "viewer_protocol_policy" {
179185
type = string
180186
description = "Limit the protocol users can use to access content. One of `allow-all`, `https-only`, or `redirect-to-https`"

0 commit comments

Comments
 (0)