Vpc Inbound Networks
Controlling Which Networks Can Reach Your VPC: Inbound CIDR Allowlists
“A load balancer on the public subnet” doesn’t mean “open to the internet” — the right posture is an explicit list of which source networks may talk to which ports. This example pairs the app VPC with an ALB scoped by inbound-network allowlists.
The configuration
module "app_vpc" {
source = "../../modules/vpc-app"
vpc_name = var.vpc_name
aws_region = var.aws_region
cidr_block = "10.0.0.0/16"
num_nat_gateways = 1
}
resource "aws_lb" "example" {
name = "inbound-networks-example"
subnets = module.app_vpc.public_subnet_ids
}
The LB lands in the public subnets — and the interesting part is what the module lets you scope around it: allow_inbound_from_cidr_blocks / per-port NACL rules that translate “office IPs + VPN range only” into subnet-level enforcement.
The three levels of “public”
| Posture | NACL/SG state | Use case |
|---|---|---|
0.0.0.0/0 |
open to world | truly public APIs/sites |
| CIDR allowlist | office/VPN ranges only | internal tools with a public-tier LB |
| Private subnets only | no public ingress at all | default for most things |
The allowlist version is the one teams skip: public subnet placement for reachability, CIDR-restricted ingress for exposure control. Layered with the SG on the LB itself, you get both stateless (NACL) and stateful (SG) enforcement of the same intent.
Takeaway
“Inbound networks” is a policy expressed in CIDRs — encode it in the module inputs once and every service inherits the boundary instead of reinventing it per resource.
Verified: reconstructed example passes terraform validate against the real vpc-app module.