Skip to content

Commit

Permalink
remove vpc_id from eip, fix *_subnets_ids
Browse files Browse the repository at this point in the history
  • Loading branch information
badra001 committed May 3, 2021
1 parent 449ed20 commit 6aed1f5
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions routing/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ resource "aws_route_table" "public" {
}

resource "aws_route_table_association" "public" {
for_each = { for subnet in var.public_subnet_ids : subnet.label => subnet }
for_each = { for subnet in var.public_subnets_ids : subnet.label => subnet }
subnet_id = each.value.id
route_table_id = aws_route_table.public[each.value.availability_zone].id
}
Expand All @@ -75,7 +75,7 @@ resource "aws_route_table" "private" {
}

resource "aws_route_table_association" "private" {
for_each = { for subnet in var.private_subnet_ids : subnet.label => subnet }
for_each = { for subnet in var.private_subnets_ids : subnet.label => subnet }
subnet_id = each.value.id
route_table_id = aws_route_table.private[each.value.availability_zone].id
}
Expand All @@ -88,7 +88,6 @@ resource "aws_route_table_association" "private" {
#---
resource "aws_eip" "nat" {
for_each = var.enable_igw && var.enable_nat ? local.availability_zones : local.empty
vpc_id = var.vpc_id
vpc = true

tags = merge(
Expand All @@ -112,11 +111,11 @@ resource "aws_internet_gateway" "gateway" {
# assume only 1 public subnet block (per AZ)
# should figure out the first one
locals {
public_subnet_ids_az = { for subnet in var.public_subnet_ids : subnet.availability_zone => subnet }
public_subnet_ids_az = { for subnet in var.public_subnets_ids : subnet.availability_zone => subnet }
}

resource "aws_nat_gateway" "nat" {
for_each = var.enable_igw && var.enable_nat ? zipmap(local.availability_zones, local.public_subnet_ids_az) : local.empty
for_each = var.enable_igw && var.enable_nat ? zipmap(local.availability_zones, local.public_subnets_ids_az) : local.empty
allocation_id = aws_eip.nat[each.key].id
subnet_id = each.value
# depends_on = [aws_internet_gateway.gateway]
Expand Down

0 comments on commit 6aed1f5

Please sign in to comment.