Skip to content

Commit c81be4c

Browse files
Add s3 gateway endpoint association
1 parent 3ff32c7 commit c81be4c

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

vpc-endpoint-s3.tf

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,10 @@ resource "aws_vpc_endpoint" "s3" {
2121
}
2222

2323
resource "aws_vpc_endpoint_route_table_association" "private" {
24-
count = var.vpc_endpoint_s3_gateway ? length(aws_subnet.private) : 0
25-
route_table_id = var.multi_nat ? aws_route_table.private[count.index].id : aws_route_table.private[0].id
24+
for_each = var.vpc_endpoint_s3_gateway ? {
25+
for idx, subnet in aws_subnet.private : idx => subnet
26+
} : {}
27+
28+
route_table_id = var.multi_nat || var.multi_az_private_rtb ? aws_route_table.private[each.key].id : aws_route_table.private[0].id
2629
vpc_endpoint_id = aws_vpc_endpoint.s3[0].id
27-
}
30+
}

0 commit comments

Comments
 (0)