From b3e78033bbee8346341a523f78f762ade41eb93b Mon Sep 17 00:00:00 2001 From: Andy Bohne Date: Sat, 3 Aug 2024 10:10:49 -0400 Subject: [PATCH] feat: Add route to `0.0.0.0/0` & `::/0` (when IPv6 is enabled) on all public route tables (#1100) * Fix logic for adding default route on public route tables * Apply suggestions from code review --------- Co-authored-by: Bryant Biggs --- main.tf | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) 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 }