Skip to content

Commit

Permalink
Fix NAT configuration and properly set Name tags
Browse files Browse the repository at this point in the history
  • Loading branch information
hellais committed Apr 19, 2024
1 parent b9e26b7 commit b4beb20
Showing 1 changed file with 16 additions and 6 deletions.
22 changes: 16 additions & 6 deletions tf/modules/network/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -52,28 +52,38 @@ resource "aws_subnet" "private" {
}
}

resource "aws_eip" "main" {
resource "aws_eip" "nat" {
count = var.az_count
domain = "vpc"
depends_on = [aws_internet_gateway.gw]
}

resource "aws_nat_gateway" "nat_gw" {
count = var.az_count
subnet_id = element(aws_subnet.private[*].id, count.index)
allocation_id = element(aws_eip.main[*].id, count.index)
count = var.az_count

allocation_id = element(aws_eip.nat[*].id, count.index)
subnet_id = element(aws_subnet.public[*].id, count.index)

depends_on = [aws_internet_gateway.gw]

tags = {
Name = "ooni-nat-gw"
}
}

resource "aws_internet_gateway" "gw" {
vpc_id = aws_vpc.main.id
tags = {
Name = "ooni-internet-gw"
}
}

resource "aws_egress_only_internet_gateway" "egress_gw" {
vpc_id = aws_vpc.main.id

tags = var.tags
tags = {
Name = "ooni-egressonly-gw"
}
}

moved {
Expand Down Expand Up @@ -120,7 +130,7 @@ resource "aws_route_table" "private" {
}

tags = {
Name = "ooni-public-route-table-${count.index}"
Name = "ooni-private-route-table-${count.index}"
}
}

Expand Down

0 comments on commit b4beb20

Please sign in to comment.