Skip to content

Commit d247d8e

Browse files
authored
fix: Addresses persistent diff with manage_default_network_acl (#737)
1 parent 668d457 commit d247d8e

File tree

3 files changed

+8
-30
lines changed

3 files changed

+8
-30
lines changed

examples/complete-vpc/README.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,6 @@ Note that this example may create resources which can cost money (AWS Elastic IP
4646
| [aws_iam_policy_document.dynamodb_endpoint_policy](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/iam_policy_document) | data source |
4747
| [aws_iam_policy_document.generic_endpoint_policy](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/iam_policy_document) | data source |
4848
| [aws_security_group.default](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/security_group) | data source |
49-
| [aws_vpc_endpoint.dynamodb](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/vpc_endpoint) | data source |
5049

5150
## Inputs
5251

examples/complete-vpc/main.tf

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -187,12 +187,6 @@ data "aws_security_group" "default" {
187187
vpc_id = module.vpc.vpc_id
188188
}
189189

190-
# Data source used to avoid race condition
191-
data "aws_vpc_endpoint" "dynamodb" {
192-
vpc_id = module.vpc.vpc_id
193-
service_name = "com.amazonaws.${local.region}.dynamodb"
194-
}
195-
196190
data "aws_iam_policy_document" "dynamodb_endpoint_policy" {
197191
statement {
198192
effect = "Deny"
@@ -208,7 +202,7 @@ data "aws_iam_policy_document" "dynamodb_endpoint_policy" {
208202
test = "StringNotEquals"
209203
variable = "aws:sourceVpce"
210204

211-
values = [data.vpc.vpc_id]
205+
values = [module.vpc.vpc_id]
212206
}
213207
}
214208
}

main.tf

Lines changed: 7 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -587,28 +587,9 @@ resource "aws_default_network_acl" "this" {
587587

588588
default_network_acl_id = aws_vpc.this[0].default_network_acl_id
589589

590-
# The value of subnet_ids should be any subnet IDs that are not set as subnet_ids
591-
# for any of the non-default network ACLs
592-
subnet_ids = setsubtract(
593-
compact(flatten([
594-
aws_subnet.public[*].id,
595-
aws_subnet.private[*].id,
596-
aws_subnet.intra[*].id,
597-
aws_subnet.database[*].id,
598-
aws_subnet.redshift[*].id,
599-
aws_subnet.elasticache[*].id,
600-
aws_subnet.outpost[*].id,
601-
])),
602-
compact(flatten([
603-
aws_network_acl.public[*].subnet_ids,
604-
aws_network_acl.private[*].subnet_ids,
605-
aws_network_acl.intra[*].subnet_ids,
606-
aws_network_acl.database[*].subnet_ids,
607-
aws_network_acl.redshift[*].subnet_ids,
608-
aws_network_acl.elasticache[*].subnet_ids,
609-
aws_network_acl.outpost[*].subnet_ids,
610-
]))
611-
)
590+
# subnet_ids is using lifecycle ignore_changes, so it is not necessary to list
591+
# any explicitly. See https://github.com/terraform-aws-modules/terraform-aws-vpc/issues/736.
592+
subnet_ids = null
612593

613594
dynamic "ingress" {
614595
for_each = var.default_network_acl_ingress
@@ -644,6 +625,10 @@ resource "aws_default_network_acl" "this" {
644625
var.tags,
645626
var.default_network_acl_tags,
646627
)
628+
629+
lifecycle {
630+
ignore_changes = [subnet_ids]
631+
}
647632
}
648633

649634
################################################################################

0 commit comments

Comments
 (0)