diff --git a/main.tf b/main.tf index 8705c1ec8..05b4f5e22 100644 --- a/main.tf +++ b/main.tf @@ -153,9 +153,9 @@ resource "aws_route_table_association" "public" { } resource "aws_route" "public_internet_gateway" { - count = local.create_public_subnets && var.create_igw ? 1 : 0 + count = local.create_public_subnets && var.create_igw ? local.num_public_route_tables : 0 - route_table_id = aws_route_table.public[0].id + route_table_id = aws_route_table.public[count.index].id destination_cidr_block = "0.0.0.0/0" gateway_id = aws_internet_gateway.this[0].id @@ -165,9 +165,9 @@ resource "aws_route" "public_internet_gateway" { } resource "aws_route" "public_internet_gateway_ipv6" { - count = local.create_public_subnets && var.create_igw && var.enable_ipv6 ? 1 : 0 + count = local.create_public_subnets && var.create_igw && var.enable_ipv6 ? local.num_public_route_tables : 0 - route_table_id = aws_route_table.public[0].id + route_table_id = aws_route_table.public[count.index].id destination_ipv6_cidr_block = "::/0" gateway_id = aws_internet_gateway.this[0].id }