Skip to content

Commit cf59461

Browse files
authored
Merge branch 'main' into module-maintainance
2 parents 663c2e2 + 1a0562c commit cf59461

File tree

2 files changed

+14
-3
lines changed

2 files changed

+14
-3
lines changed

variables.tf

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,18 @@ variable "cloudfront_enable_compression" {
184184
default = false
185185
}
186186

187+
variable "cloudfront_default_cache_policy_id" {
188+
description = "(Optional) The cache policy ID for the default cache behavior. Defaults to Managed-CachingOptimized (658327ea-f89d-4fab-a63d-7e88639e58f6). Use 4135ea2d-6df8-44a3-9df3-4b5a84be39ad for Managed-CachingDisabled."
189+
type = string
190+
default = "658327ea-f89d-4fab-a63d-7e88639e58f6"
191+
}
192+
193+
variable "cloudfront_default_origin_request_policy_id" {
194+
description = "(Optional) The origin request policy ID for the default cache behavior. Defaults to Managed-CORS-S3Origin (88a5eaf4-2fd4-4709-b370-b4c650ea3fcf)."
195+
type = string
196+
default = "88a5eaf4-2fd4-4709-b370-b4c650ea3fcf"
197+
}
198+
187199
variable "cloudfront_function_association" {
188200
description = "(Optional - up to 2 per distribution) List containing information to associate a CF function to cloudfront. The first field is `event_type` of the CF function associated with default cache behavior, it can be viewer-request or viewer-response"
189201
type = list(object({

website.tf

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -150,10 +150,9 @@ resource "aws_cloudfront_distribution" "website" {
150150
# TODO - Add variable for Custom Error Responses
151151
# custom_error_response (Optional) - One or more custom error response elements (multiples allowed).
152152

153-
# TODO - Add variables for cache and origin request policies.
154153
default_cache_behavior {
155-
cache_policy_id = "658327ea-f89d-4fab-a63d-7e88639e58f6" # Managed-CachingOptimized
156-
origin_request_policy_id = "88a5eaf4-2fd4-4709-b370-b4c650ea3fcf" # Managed-CORS-S3Origin
154+
cache_policy_id = var.cloudfront_default_cache_policy_id
155+
origin_request_policy_id = var.cloudfront_default_origin_request_policy_id
157156
allowed_methods = var.cloudfront_allowed_cached_methods
158157
cached_methods = var.cloudfront_allowed_cached_methods
159158
target_origin_id = local.website_bucket_name

0 commit comments

Comments
 (0)