-
-
Notifications
You must be signed in to change notification settings - Fork 72
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix variable enabled=false results in errors (#47)
* Fix module enabled=false produces errors * Add local availability_zones which is empty if disabled * private_count and public_count are either 0 if disabled or the length of the local.availability_zones list * therefore aws resource counts will not reference empty list in element function * also guaranteed to have same number of elements in zipmap function * Added convenience local lists of tuples for outputs * Note az_ngw_ids is now an empty map if disabled - previously a map of constant "0" * dummy_az_ngw_ids is no longer referenced so remove * Transform local lists of tuples to output maps * since private_count and public_count are not both >0, no ellipsis needed in transform, producing single map value * output maps are all empty if disabled * Multiple TF 0.13 cleanups Co-authored-by: Paul Robinson <paul.robinson@internetfusion.co.uk> Co-authored-by: Nuru <Nuru@users.noreply.github.com>
- Loading branch information
1 parent
5e04ef2
commit 4e3780d
Showing
19 changed files
with
309 additions
and
237 deletions.
There are no files selected for viewing
Validating CODEOWNERS rules …
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,7 @@ | ||
name: Validate Codeowners | ||
on: | ||
workflow_dispatch: | ||
|
||
pull_request: | ||
|
||
jobs: | ||
|
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
enabled = false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
enabled = true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,15 @@ | ||
locals { | ||
public_enabled = module.this.enabled && var.type == "public" | ||
private_enabled = module.this.enabled && var.type == "private" | ||
enabled = module.this.enabled | ||
|
||
public_enabled = local.enabled && var.type == "public" | ||
private_enabled = local.enabled && var.type == "private" | ||
availability_zones = local.enabled ? var.availability_zones : [] | ||
|
||
output_map = { for az in(local.enabled ? var.availability_zones : []) : az => { | ||
subnet_id = local.public_enabled ? aws_subnet.public[az].id : aws_subnet.private[az].id | ||
subnet_arn = local.public_enabled ? aws_subnet.public[az].arn : aws_subnet.private[az].arn | ||
route_table_id = local.public_enabled ? aws_route_table.public[az].id : aws_route_table.private[az].id | ||
ngw_id = local.public_enabled ? aws_nat_gateway.public[az].id : null | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,32 +1,25 @@ | ||
output "az_subnet_ids" { | ||
value = zipmap( | ||
var.availability_zones, | ||
coalescelist(aws_subnet.private.*.id, aws_subnet.public.*.id), | ||
) | ||
value = { for az, m in local.output_map : az => m.subnet_id } | ||
description = "Map of AZ names to subnet IDs" | ||
} | ||
|
||
output "az_subnet_arns" { | ||
value = { for az, m in local.output_map : az => m.subnet_arn } | ||
description = "Map of AZ names to subnet ARNs" | ||
} | ||
|
||
output "az_route_table_ids" { | ||
value = zipmap( | ||
var.availability_zones, | ||
coalescelist(aws_route_table.private.*.id, aws_route_table.public.*.id), | ||
) | ||
value = { for az, m in local.output_map : az => m.route_table_id } | ||
description = " Map of AZ names to Route Table IDs" | ||
} | ||
|
||
output "az_ngw_ids" { | ||
value = zipmap( | ||
var.availability_zones, | ||
coalescelist(aws_nat_gateway.public.*.id, local.dummy_az_ngw_ids), | ||
) | ||
# No ellipsis needed since this module makes either public or private subnets. See the TF 0.15 one function | ||
value = { for az, m in local.output_map : az => m.ngw_id } | ||
description = "Map of AZ names to NAT Gateway IDs (only for public subnets)" | ||
} | ||
|
||
output "az_subnet_arns" { | ||
value = zipmap( | ||
var.availability_zones, | ||
coalescelist(aws_subnet.private.*.arn, aws_subnet.public.*.arn), | ||
) | ||
description = "Map of AZ names to subnet ARNs" | ||
} | ||
|
||
output "az_subnet_map" { | ||
value = local.output_map | ||
description = "Map of AZ names to map of information about subnets" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.