File tree Expand file tree Collapse file tree 2 files changed +39
-4
lines changed
Expand file tree Collapse file tree 2 files changed +39
-4
lines changed Original file line number Diff line number Diff line change 1+ module "website_default" {
2+ source = " ../../"
3+
4+ namespace = var. namespace
5+ stage = var. stage
6+ name = var. name
7+
8+ // Distinguish this module instance from the one in main.tf and prevent S3 bucket name collisions
9+ attributes = concat (var. attributes , [" website" ])
10+
11+ cloudfront_access_logging_enabled = false
12+
13+ website_enabled = true
14+
15+ context = module. this . context
16+ }
17+
18+ module "website_redirect_all" {
19+ source = " ../../"
20+
21+ namespace = var. namespace
22+ stage = var. stage
23+ name = var. name
24+
25+ // Distinguish this module instance from the one in main.tf and prevent S3 bucket name collisions
26+ attributes = concat (var. attributes , [" website-redirect-all" ])
27+
28+ cloudfront_access_logging_enabled = false
29+
30+ website_enabled = true
31+ redirect_all_requests_to = " https://cloudposse.com"
32+
33+ context = module. this . context
34+ }
Original file line number Diff line number Diff line change @@ -319,11 +319,12 @@ resource "aws_s3_bucket" "origin" {
319319
320320 dynamic "website" {
321321 for_each = var. website_enabled ? local. website_config [var . redirect_all_requests_to == " " ? " default" : " redirect_all" ] : []
322+ # The lookup is needed to safely access optional website config keys, since locals defines 2 distinct flavours of website config
322323 content {
323- error_document = website. value . error_document
324- index_document = website. value . index_document
325- redirect_all_requests_to = website. value . redirect_all_requests_to
326- routing_rules = website. value . routing_rules
324+ error_document = lookup ( website. value , " error_document" , null )
325+ index_document = lookup ( website. value , " index_document" , null )
326+ redirect_all_requests_to = lookup ( website. value , " redirect_all_requests_to" , null )
327+ routing_rules = lookup ( website. value , " routing_rules" , null )
327328 }
328329 }
329330}
You can’t perform that action at this time.
0 commit comments