-
-
Notifications
You must be signed in to change notification settings - Fork 4.6k
Description
Not sure whether to file this under "feature", or "bug"; I suppose it depends on how a person views subnetting in AWS VPC.
Basically, I have 6 private subnets calculated from a base /16 prefix, and being created in the eu-west-1 region as follows:
private_subnets = [
"${cidrsubnet(var.cidr_block, 7, 7)}",
"${cidrsubnet(var.cidr_block, 7, 8)}",
"${cidrsubnet(var.cidr_block, 7, 9)}",
"${cidrsubnet(var.cidr_block, 4, 13)}",
"${cidrsubnet(var.cidr_block, 4, 14)}",
"${cidrsubnet(var.cidr_block, 4, 15)}",
]
In the module definition, I have also specified to use all 3 availability zones eu-west-1a, eu-west-1b, and eu-west-1c. The module then generates 6 NAT gateways that look like this:
+ module.vpc.aws_route.private_nat_gateway[X]
id: <computed>
destination_cidr_block: "0.0.0.0/0"
destination_prefix_list_id: <computed>
egress_only_gateway_id: <computed>
gateway_id: <computed>
instance_id: <computed>
instance_owner_id: <computed>
nat_gateway_id: "${element(aws_nat_gateway.this.*.id, count.index)}"
network_interface_id: <computed>
origin: <computed>
route_table_id: "${element(aws_route_table.private.*.id, count.index)}"
state: <computed>
My question: isn't one NAT gateway per private subnet a bit excessive? If the number of availability zones is defined by ${length(var.azs)}, then shouldn't only ${length(var.azs)} number of NAT gateways be created, and added to the route tables?
This is especially true as a person's user account is charged per hour that each NAT gateway instance is running: https://aws.amazon.com/vpc/pricing/#natgatewaypricing
My info:
Terraform v0.11.7
Provider.aws v1.14.0
Module version: 1.30.0