Official AWS VPC Module, multiple private RTs?

Hey all,

I’m trying to understand why when I have this code below I always end up with 3x RTs for the private subnets.

https://registry.terraform.io/modules/terraform-aws-modules/vpc/aws/latest

locals {
  vpc_name            = "my-vpc"
  vpc_subnets_private = ["10.0.1.0/24", "10.0.2.0/24", "10.0.3.0/24"]
  vpc_subnets_public  = ["10.0.51.0/24", "10.0.52.0/24", "10.0.53.0/24"]
  vpc_subnets_intra   = ["10.0.101.0/24", "10.0.102.0/24", "10.0.103.0/24"]
}

module "vpc" {
  source  = "terraform-aws-modules/vpc/aws"
  version = "3.12.0"

  name = local.vpc_name
  cidr = "10.0.0.0/16"

  azs             = ["eu-west-1a", "eu-west-1b", "eu-west-1c"]
  private_subnets = local.vpc_subnets_private
  public_subnets  = local.vpc_subnets_public
  intra_subnets   = local.vpc_subnets_intra

  tags = {
    terraform-created = "true"
    environment       = local.env_short
  }
}

I’m also attaching a screenshot showing the console output.

Anyone know how I can alter the module to behave like for the public and intra subnets?

// David

Well, it depends which type of NAT Gateway configuration you’re looking for.

The setting single_nat_gateway = true would change the number of route tables however depends on your needs.

1 Like

Thank you so much, that fixed my issue! :pray:t3: