FreeConceptAWSVPC
VPC basics: public and private subnets
In one sentence: Public subnets face the internet; private subnets can reach out but can’t be reached directly.
Animated diagrams are not available for printing. Get StackKinetic Pro to download this explainer.
Inspect:
Read this explainer as text
Inbound request
Beginner
- A visitor’s request arrives at your network’s front gate.
- The gate lets it through to the lobby, where the greeter waits.
- The greeter walks the request to the app in a back room.
- The app hands back its answer.
- The greeter carries it back to the front gate.
- The visitor gets their page, without ever knowing where the back room is.
Practitioner
- Traffic enters the VPC through the internet gateway.
- It reaches the load balancer in a public subnet.
- The load balancer forwards to the private app server.
- The app server responds to the load balancer.
- The load balancer sends the response out.
- The response reaches the user. The app was never directly exposed.
Architect
- Inbound flow to the ALB’s public IP is translated by the IGW.
- Public route table and the ALB’s security group allow 443 from anywhere.
- Target traffic stays inside the VPC; the app’s security group only trusts the ALB’s.
- Response returns on the same connection.
- Stateful security groups allow the return traffic automatically.
- Round trip complete; the app has no public IP and no inbound route from the internet.
App calls out
Beginner
- The app needs a software update, so it sends a request to the mail room.
- The mail room swaps the return address for its own and sends it out.
- The request goes out to the internet.
- The update server replies to the mail room’s address.
- The reply arrives at the mail room.
- The mail room passes it to the app. Strangers still can’t start a conversation with the app.
Practitioner
- The private app sends outbound traffic to the NAT gateway.
- NAT replaces the private source address with its public one.
- Traffic leaves the VPC.
- The reply comes back to the NAT’s public address.
- The internet gateway hands it to the NAT gateway.
- NAT forwards the reply to the private instance.
Architect
- Private route table sends 0.0.0.0/0 to the NAT gateway in the same zone.
- Source NAT to the NAT gateway’s Elastic IP, then out via the IGW.
- Egress to the update server.
- Return traffic matches the NAT’s connection-tracking entry.
- Delivered to the NAT gateway.
- Translated back to the private IP. Unsolicited inbound connections have no mapping and are dropped.
Now add…
Take it with you
Pro adds video downloads, with embeds and editable source coming soon. Core explainers are always free to watch.