Vpc Subnets Disabled
When You Want a VPC Without Subnets (Yes, Really)
Sometimes you want the VPC shell — routing, NACLs, flow logs, DNS — but plan to create subnets later or under different control. The vpc-app module supports disabling any subnet tier, and this example exercises every combination.
Four module calls, four configurations
module "vpc_app_example_public_subnets_disabled" {
source = "../../modules/vpc-app"
vpc_name = "${var.vpc_name}-public-disabled"
cidr_block = "10.0.0.0/16"
num_nat_gateways = 1
create_public_subnets = false
}
module "vpc_app_example_private_app_subnets_disabled" {
source = "../../modules/vpc-app"
vpc_name = "${var.vpc_name}-private-app-disabled"
cidr_block = "10.2.0.0/16"
create_private_app_subnets = false
}
module "vpc_app_example_private_persistence_subnets_disabled" {
source = "../../modules/vpc-app"
vpc_name = "${var.vpc_name}-persistence-disabled"
cidr_block = "10.4.0.0/16"
create_private_persistence_subnets = false
}
module "vpc_app_example_all_subnets_disabled" {
source = "../../modules/vpc-app"
vpc_name = "${var.vpc_name}-all-disabled"
cidr_block = "10.6.0.0/16"
create_public_subnets = false
create_private_app_subnets = false
create_private_persistence_subnets = false
}
Note the non-overlapping CIDRs (10.0, 10.2, 10.4, 10.6) — four VPCs in one example, each free to peer later.
When you’d actually do this
- Shared-services / transit VPCs — a VPC that exists only to host TGW attachments, resolver endpoints, or peering links needs no subnets of its own initially
- Subnets managed elsewhere — some orgs create subnets in a second Terraform workspace (network team owns VPC shell, app teams own subnets)
- Persistence-tier-less services — a stateless app stack doesn’t need a persistence tier at all; disabling it skips the route tables, NACL rules, and subnet math for a tier that will never hold anything
Takeaway
Optional tiers keep the module honest about its defaults: the three-tier layout is an option set, not dogma. Disable what the workload doesn’t use.
Verified: reconstructed example passes terraform validate against the real vpc-app module.