DEV Community

Himanshu Rathore
Himanshu Rathore

Posted on

The Infrastructure Blueprint: A Deep Dive into AWS VPC

If you’ve spent any time in AWS, you’ve probably clicked "Create VPC" more times than you can count. But there’s a massive difference between setting up a VPC that works and designing a VPC that is resilient, secure, and ready for a 2:00 AM traffic spike.

Think of a Virtual Private Cloud (VPC) not just as a "private network," but as the foundational blast radius for your entire cloud footprint. In this deep dive, we’re going to peel back the layers on how networking actually works under the hood at AWS.

1. The Address Space: Why CIDR Choice Still Matters
When you define your VPC CIDR (Classless Inter-Domain Routing), like 10.0.0.0/16, you are making a decision you might have to live with for years.

The Human Reality: Most people default to /16 because 65,536 IPs sound like "enough." But the real danger isn't running out of IPs—it’s overlapping ranges. If you ever want to connect your VPC to an on-premise data center or another VPC via Peering or Transit Gateway, and both use 10.0.0.0/16, you’re in for a world of routing pain.

Pro-tip: Use the secondary CIDR block feature if you get stuck, but try to coordinate your IP plan across your entire organization early. Also, remember that AWS reserves 5 IP addresses in every subnet. If you create a tiny /28 subnet (16 IPs), you only actually get 11.

2. Subnets: Segregation by Design
Subnets are where your resources actually live. The common pattern is Public vs. Private, but let’s look closer:

Public Subnets: These have a route to an Internet Gateway (IGW). This is where your Load Balancers or Bastion hosts live.

Private Subnets: No direct route to the IGW. They use a NAT Gateway (placed in a public subnet) to talk to the outside world.

Isolated Subnets: No IGW, no NAT. Just local VPC traffic. This is the gold standard for your databases (RDS).

The Multi-AZ Rule

Never, ever put all your subnets in one Availability Zone (AZ). If us-east-1a has a bad day, your app shouldn't. A "production-ready" VPC always mirrors its subnet structure across at least two (ideally three) AZs.

3. The Gatekeepers: Security Groups vs. NACLs
This is where most configuration errors happen. People often treat them as the same thing, but they operate on completely different logic.

The "Gotcha": If you use NACLs, you must remember to open Ephemeral Ports (typically 1024-65535). If you allow inbound traffic on port 80 but forget to allow outbound traffic on the ephemeral range, the connection will time out because the NACL is stateless.

4. Connecting the Dots: Peering, Endpoints, and Transit Gateway
As your architecture grows, one VPC isn't enough. How do you link them?

VPC Peering: Great for simple 1-to-1 connections. It’s free to set up, but doesn't support "transitive routing" (VPC A can talk to B, B to C, but A can't talk to C through B).

Transit Gateway (TGW): The "Hub and Spoke" model. If you have 10+ VPCs, TGW is your best friend. It acts as a central router.

VPC Endpoints (PrivateLink): This is the "secret sauce" for security and cost. Normally, if an EC2 instance in a private subnet wants to talk to S3, the traffic goes out the NAT Gateway to the public internet. With an S3 Endpoint, that traffic never leaves the AWS backbone. It’s faster, more secure, and saves you money on NAT Gateway data processing fees.

5. Modern Observability: VPC Flow Logs
You can't fix what you can't see. VPC Flow Logs capture information about the IP traffic going to and from network interfaces.

When a developer says, "I can't reach the database," the Flow Logs will tell you exactly where the REJECT is happening. Is it the Security Group? The NACL? The Flow Logs don't lie.

Final Thoughts: The "Zero Trust" Mindset

In 2026, we don't just rely on the VPC boundary. We use Identity-Based Security (IAM) alongside Network-Based Security (VPC).

A well-designed VPC is invisible when it works, but it’s the first thing people notice when it fails. Start with a clean CIDR plan, stick to a multi-AZ layout, and use Endpoints whenever possible. Your future self (the one not getting paged at 2 AM) will thank you.

Top comments (0)