VPC Fundamentals
VPC Fundamentals
A Virtual Private Cloud (VPC) is your logically isolated section of the AWS cloud. Think of it as your own data center inside AWS — you control the IP address ranges, subnets, routing, and access controls completely. Every EC2 instance, RDS database, Lambda function in a VPC, and EKS node lives inside one. Getting VPC design right at the start is one of the highest-leverage decisions in any AWS workload; retrofitting networking is painful at scale.
Why VPCs Exist
Before VPCs (the EC2-Classic era), all instances shared a flat, AWS-managed network. Any instance could reach any other. VPCs, introduced in 2009 and made the default in 2013, give you network isolation at the infrastructure level — not just security-group rules. Your resources are unreachable by default; you explicitly permit traffic inbound and outbound.
At companies like Amazon, Google, and Meta, networking teams enforce strict blast-radius constraints: a misconfiguration or compromise in one environment must not propagate to another. VPC isolation is the first enforcement layer.
CIDR Planning — the Decision That Ages
Every VPC has a primary CIDR block — a range of private IP addresses expressed in CIDR notation. Once assigned, you cannot shrink it; you can only add secondary CIDRs (up to 4 additional, max /28 to /16 each). Choose too small and you run out of IPs under load. Choose carelessly and you create overlapping ranges that make VPC peering, Transit Gateway, and on-premises VPN connections impossible.
10.0.0.0/8 — ~16.7 million addresses (most headroom)
172.16.0.0/12 — ~1 million addresses
192.168.0.0/16 — ~65,000 addresses (too small for production)
Practical CIDR Strategy for Multi-Account AWS
In a real organization running AWS Organizations with dozens of accounts, you need a global IP plan. A common pattern used at scale:
- Allocate a /8 or /10 supernet to the entire organization from your private address space.
- Divide by environment:
10.0.0.0/12for production,10.16.0.0/12for staging,10.32.0.0/12for dev. - Further divide by region: within production,
10.0.0.0/14forus-east-1,10.4.0.0/14foreu-west-1. - Each VPC gets a /16 from its region's block — 65,536 addresses, enough for most workloads.
- Subnets are carved out of the VPC CIDR as /24 (254 usable) or /22 (1,022 usable) slices.
Default VPC vs Custom VPC
AWS creates a default VPC in every region for every account. It uses 172.31.0.0/16 and creates a /20 default subnet in each Availability Zone with auto-assign public IPs enabled. This is intentionally permissive for experimentation — not for production.
Problems with the default VPC in production environments:
- Instances launched without explicitly choosing a subnet land in the default VPC and get public IPs automatically — a serious accidental exposure risk.
- The
172.31.0.0/16range frequently conflicts with corporate VPNs and on-premises networks. - No granular subnet structure — no separation between public-facing, private application, and data tiers.
- SCP (Service Control Policies) at many companies now deny use of the default VPC entirely.
Creating a Custom VPC — CLI and Terraform
Creating a VPC via the AWS CLI is straightforward. Here you create a VPC, tag it, and enable DNS support (required for private hosted zones and EKS):
In production, you should manage VPCs with Terraform or AWS CloudFormation, not the CLI, so the configuration is version-controlled, auditable, and repeatable. A minimal Terraform VPC block looks like this:
Anatomy of a VPC: What Lives Inside
A VPC is a container for several interconnected constructs — all of which you will configure in subsequent lessons. At a high level, every production VPC includes:
- Subnets — partitions of the CIDR across Availability Zones (lesson 2)
- Route Tables — per-subnet routing rules directing traffic toward gateways (lesson 2)
- Internet Gateway (IGW) — the door to the public internet for public subnets (lesson 2)
- NAT Gateway — outbound-only internet access for private subnets (lesson 2)
- Security Groups — stateful firewall rules attached to ENIs (lesson 3)
- Network ACLs — stateless subnet-level firewall rules (lesson 3)
VPC Architecture Diagram
Key Production Considerations
- Always deploy across at least 2 AZs — one AZ failure must not take down your service.
- Separate tiers into separate subnets — public (load balancers), private (application), data (RDS, ElastiCache). This gives you granular routing and NACL control.
- Reserve address space — leave at least one /24 per AZ per tier unallocated for future services. Running out of IPs in a live VPC is an extremely painful migration.
- Tag everything —
Name,Env,Team,CostCentertags on every VPC and subnet. AWS Cost Explorer, Resource Groups, and compliance tooling all rely on tags. - Enable VPC Flow Logs from day one — sent to CloudWatch Logs or S3, these are essential for security investigations and network troubleshooting (lesson 9). Enabling them retroactively after an incident is too late.