Services

Resources

Company

VPC (Virtual Private Cloud)

A VPC (Virtual Private Cloud) is a private network you define inside a cloud provider. In AWS it lives in one region, owns one or more CIDR blocks, and reaches into each Availability Zone through its subnets. Instances, databases, load balancers and EKS nodes all get their private IPs from it. Nothing enters or leaves until you add a gateway and a route.

How it works

Each subnet uses one route table. Every table starts with a local route for the VPC range, so all subnets can talk to each other. Add 0.0.0.0/0 pointing at an internet gateway and the subnet becomes public. A private subnet points that route at a NAT gateway instead. Its instances can download patches, but nothing outside can open a connection to them.

Two firewalls sit on top. Security groups attach to network interfaces, hold allow rules only, and are stateful, so reply traffic is let back in. Network ACLs attach to subnets, run numbered rules in order, and can deny. They are stateless, so replies on ports 1024 to 65535 need their own rule. Most teams do the real filtering in security groups.

VPCs connect in two ways. Peering links exactly two VPCs, is not transitive, and refuses overlapping ranges. A Transit Gateway is a hub that each VPC attaches to once. For 10 VPCs that talk to each other, a full peering mesh needs 10 x 9 / 2 = 45 connections, against 10 attachments.

One2N's post on reaching private EC2 instances shows a third pattern. The instance sits in a private subnet with no public IP, no key pair and a security group with no inbound rules. To open a shell, its SSM agent must reach the Systems Manager API over HTTPS. With no route out of the subnet, that call has nowhere to go.

The fix is two interface VPC endpoints, com.amazonaws.us-east-1.ssm and com.amazonaws.us-east-1.ssmmessages, placed in the private subnets. Each endpoint is a network interface with a private IP, built on AWS PrivateLink. Its own security group accepts port 443 only from the instance security group. Session Manager then works with no internet path at all.

Why it matters in production

Mistakes in a VPC are slow to undo. The primary range cannot change after creation, and two VPCs that both picked 10.0.0.0/16 can never peer. NAT gateways bill per hour and per GB, so private nodes pulling images through one pay for every gigabyte. An S3 gateway endpoint carries that traffic for free. Endpoints and Session Manager also remove the need for a bastion host with port 22 open.

See also

On the One2N blog

References

  1. Amazon VPC User Guide: What is Amazon VPC?

  2. Amazon VPC User Guide: Control subnet traffic with network access control lists

Diagram of a VPC: traffic from the internet passes an internet gateway on the VPC edge, reaches a load balancer in the public subnet, then an app server in the private subnet. A red dashed line marks that the private server has no route out to the internet. A VPC endpoint below the server gives it a private path to AWS services instead.