Skip to content

Commit 734b76b

Browse files
committed
feat(vpc): simplify network with one gw per subnet with one ip per gw
1 parent 801f34c commit 734b76b

File tree

1 file changed

+1
-20
lines changed

1 file changed

+1
-20
lines changed

vpc.tf

Lines changed: 1 addition & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,10 @@
1-
resource "aws_eip" "nat_eip" {
2-
count = 2
3-
domain = "vpc"
4-
}
5-
61
module "vpc" {
72
source = "terraform-aws-modules/vpc/aws"
83
version = "5.13.0"
94

105
name = "${local.cluster_name}-vpc"
116
cidr = "10.0.0.0/16" # cannot be less then /16 (more ips)
127

13-
148
# dual stack https://github.com/terraform-aws-modules/terraform-aws-vpc/blob/v5.13.0/examples/ipv6-dualstack/main.tf
159
enable_ipv6 = true
1610
public_subnet_assign_ipv6_address_on_creation = true
@@ -32,8 +26,7 @@ module "vpc" {
3226
# next for eks agents
3327
"10.0.4.0/23", # 10.0.4.1 -> 10.0.5.254 (510 ips)
3428
]
35-
public_subnets = [ # need at least one for the module (line 1085 : subnet_id = element(aws_subnet.public[*].id,var.single_nat_gateway ? 0 : count.index,))
36-
#fake one
29+
public_subnets = [ # need at least one public network to host the NAT gateways
3730
"10.0.255.0/24", # 10.0.255.1 -> 10.0.255.254 (254 ips)
3831
]
3932

@@ -46,19 +39,7 @@ module "vpc" {
4639
enable_nat_gateway = true
4740
single_nat_gateway = false
4841
one_nat_gateway_per_az = false
49-
###### I cannot find a way to set a multiple IP for outgoing GW ... the count is not working
50-
###### https://registry.terraform.io/modules/terraform-aws-modules/vpc/aws/latest#external-nat-gateway-ips
51-
######
52-
###### https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/nat_gateway
53-
######
54-
reuse_nat_ips = true # <= Skip creation of EIPs for the NAT Gateways
55-
external_nat_ip_ids = aws_eip.nat_eip.*.id # <= IPs specified here as input to the module
56-
###### I may have to create those aws_eip with name nat manually
5742

5843
enable_dns_hostnames = true
5944

60-
public_subnet_tags = {
61-
"kubernetes.io/role/internal-elb" = 1 ###TODO CHECK
62-
}
63-
6445
}

0 commit comments

Comments
 (0)