Skip to content

Commit

Permalink
simplify vpc route table
Browse files Browse the repository at this point in the history
  • Loading branch information
guyzsarun committed Dec 17, 2023
1 parent c152a20 commit a8f22db
Showing 1 changed file with 4 additions and 10 deletions.
14 changes: 4 additions & 10 deletions vpc.tf
Original file line number Diff line number Diff line change
Expand Up @@ -65,21 +65,15 @@ resource "aws_route_table" "main-vpc-private-routetable" {
}

resource "aws_route_table_association" "route-assoc-private" {
subnet_id = aws_subnet.main-vpc-subnet-private[count.index].id
subnet_id = each.value.id
route_table_id = aws_route_table.main-vpc-private-routetable.id
count = length(aws_subnet.main-vpc-subnet-private)


depends_on = [aws_subnet.main-vpc-subnet-private]
for_each = { for i, subnet in aws_subnet.main-vpc-subnet-private : subnet.id => subnet }
}

resource "aws_route_table_association" "route-assoc-public" {
subnet_id = aws_subnet.main-vpc-subnet-public[count.index].id
subnet_id = each.value.id
route_table_id = aws_route_table.main-vpc-public-routetable.id
count = length(aws_subnet.main-vpc-subnet-public)


depends_on = [aws_subnet.main-vpc-subnet-public]
for_each = { for i, subnet in aws_subnet.main-vpc-subnet-public : subnet.id => subnet }
}

resource "aws_internet_gateway" "gw" {
Expand Down

0 comments on commit a8f22db

Please sign in to comment.