Skip to content

Commit 743798d

Browse files
authored
fix: Add dns64 routes (#924)
1 parent 6051692 commit 743798d

File tree

3 files changed

+27
-1
lines changed

3 files changed

+27
-1
lines changed

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -310,9 +310,11 @@ No modules.
310310
| [aws_network_acl_rule.redshift_inbound](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/network_acl_rule) | resource |
311311
| [aws_network_acl_rule.redshift_outbound](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/network_acl_rule) | resource |
312312
| [aws_redshift_subnet_group.redshift](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/redshift_subnet_group) | resource |
313+
| [aws_route.database_dns64_nat_gateway](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/route) | resource |
313314
| [aws_route.database_internet_gateway](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/route) | resource |
314315
| [aws_route.database_ipv6_egress](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/route) | resource |
315316
| [aws_route.database_nat_gateway](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/route) | resource |
317+
| [aws_route.private_dns64_nat_gateway](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/route) | resource |
316318
| [aws_route.private_ipv6_egress](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/route) | resource |
317319
| [aws_route.private_nat_gateway](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/route) | resource |
318320
| [aws_route.public_internet_gateway](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/route) | resource |

examples/ipv6-dualstack/main.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ module "vpc" {
3333
public_subnets = [for k, v in local.azs : cidrsubnet(local.vpc_cidr, 8, k + 4)]
3434
database_subnets = [for k, v in local.azs : cidrsubnet(local.vpc_cidr, 8, k + 8)]
3535

36-
enable_nat_gateway = false
36+
enable_nat_gateway = true
3737

3838
create_database_subnet_route_table = true
3939
create_database_internet_gateway_route = true

main.tf

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -436,6 +436,18 @@ resource "aws_route" "database_nat_gateway" {
436436
}
437437
}
438438

439+
resource "aws_route" "database_dns64_nat_gateway" {
440+
count = local.create_database_route_table && !var.create_database_internet_gateway_route && var.create_database_nat_gateway_route && var.enable_nat_gateway && var.enable_ipv6 && var.private_subnet_enable_dns64 ? var.single_nat_gateway ? 1 : local.len_database_subnets : 0
441+
442+
route_table_id = element(aws_route_table.database[*].id, count.index)
443+
destination_ipv6_cidr_block = "64:ff9b::/96"
444+
nat_gateway_id = element(aws_nat_gateway.this[*].id, count.index)
445+
446+
timeouts {
447+
create = "5m"
448+
}
449+
}
450+
439451
resource "aws_route" "database_ipv6_egress" {
440452
count = local.create_database_route_table && var.create_egress_only_igw && var.enable_ipv6 && var.create_database_internet_gateway_route ? 1 : 0
441453

@@ -1081,6 +1093,18 @@ resource "aws_route" "private_nat_gateway" {
10811093
}
10821094
}
10831095

1096+
resource "aws_route" "private_dns64_nat_gateway" {
1097+
count = local.create_vpc && var.enable_nat_gateway && var.enable_ipv6 && var.private_subnet_enable_dns64 ? local.nat_gateway_count : 0
1098+
1099+
route_table_id = element(aws_route_table.private[*].id, count.index)
1100+
destination_ipv6_cidr_block = "64:ff9b::/96"
1101+
nat_gateway_id = element(aws_nat_gateway.this[*].id, count.index)
1102+
1103+
timeouts {
1104+
create = "5m"
1105+
}
1106+
}
1107+
10841108
################################################################################
10851109
# Customer Gateways
10861110
################################################################################

0 commit comments

Comments
 (0)