Skip to content

Commit

Permalink
feat: Add route to 0.0.0.0/0 & ::/0 (when IPv6 is enabled) on all…
Browse files Browse the repository at this point in the history
… public route tables (#1100)

* Fix logic for adding default route on public route tables

* Apply suggestions from code review

---------

Co-authored-by: Bryant Biggs <[email protected]>
  • Loading branch information
abohne and bryantbiggs authored Aug 3, 2024
1 parent 545f4d5 commit b3e7803
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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
}
Expand Down

0 comments on commit b3e7803

Please sign in to comment.