Skip to content

NAT Gateway(s) created in wrong subnet(s) - should be able to define which subnets to useย #1257

@jymgologic

Description

@jymgologic

terraform-aws-vpc/main.tf

Lines 1237 to 1240 in b3fb14f

subnet_id = element(
aws_subnet.public[*].id,
var.single_nat_gateway ? 0 : count.index,
)

The problem here is that the multiple subnets created in this module could be greater than the amount of AZs. So in my VPC sharing scenario, I end up having my NAT Gateways in the wrong subnets. Basically unless you create a number of public subnet = AZs you could have the same problem.

Solution?

  • (Prefered) Would probably means an extra list(string) variable for defining the subnet(s) name(s) where the NAT Gateway should be put in.
  • Restrict/validate the amount of public subnets not to be greater than the amount of AZs

Workaround, keep your public subnets that will have the NAT Gateways to be firsts in the list.

Can work on a PR if the direction is good, thanks for the feedbacks!

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions