Skip to content

Commit

Permalink
fix: Resource aws_default_network_acl orphaned subnet_ids (terraform-…
Browse files Browse the repository at this point in the history
  • Loading branch information
jeremyciak authored and harrythebot committed May 11, 2022
1 parent 8c30e6e commit b74b75d
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 2 deletions.
5 changes: 3 additions & 2 deletions examples/network-acls/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,11 @@ module "vpc" {
local.network_acls["elasticache_outbound"],
)

private_dedicated_network_acl = true
private_dedicated_network_acl = false
elasticache_dedicated_network_acl = true

manage_default_network_acl = true

enable_ipv6 = true

enable_nat_gateway = false
Expand Down Expand Up @@ -200,4 +202,3 @@ locals {
]
}
}

21 changes: 21 additions & 0 deletions main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -534,6 +534,27 @@ resource "aws_default_network_acl" "this" {

default_network_acl_id = element(concat(aws_vpc.this.*.default_network_acl_id, [""]), 0)

# The value of subnet_ids should be any subnet IDs that are not set as subnet_ids
# for any of the non-default network ACLs
subnet_ids = setsubtract(
compact(flatten([
aws_subnet.public.*.id,
aws_subnet.private.*.id,
aws_subnet.intra.*.id,
aws_subnet.database.*.id,
aws_subnet.redshift.*.id,
aws_subnet.elasticache.*.id,
])),
compact(flatten([
aws_network_acl.public.*.subnet_ids,
aws_network_acl.private.*.subnet_ids,
aws_network_acl.intra.*.subnet_ids,
aws_network_acl.database.*.subnet_ids,
aws_network_acl.redshift.*.subnet_ids,
aws_network_acl.elasticache.*.subnet_ids,
]))
)

dynamic "ingress" {
for_each = var.default_network_acl_ingress
content {
Expand Down

0 comments on commit b74b75d

Please sign in to comment.