Public vs Private: Gateways & Route Tables

What actually makes a subnet public, and how private servers still reach the internet.

1 min read

A subnet isn't public because of its name. It's public because its route table sends internet traffic to an Internet Gateway.

  • Internet Gateway (IGW): a two-way door between your VPC and the internet. Resources in public subnets with public IPs can be reached from outside.
  • NAT Gateway: a one-way door. Instances in private subnets can reach out (to download updates or call APIs), but nothing from the internet can start a connection in.
  • Route table: a list of "for this destination, go here" rules attached to subnets.
Route tableDestinationTarget
public10.0.0.0/16local (inside the VPC)
public0.0.0.0/0Internet Gateway
private10.0.0.0/16local
private0.0.0.0/0NAT Gateway (in a public subnet)
How it flows
  1. 1Internet

    Users and APIs

  2. 2Internet Gateway

    Two-way door

  3. 3Public subnet

    Load balancer, NAT gateway

  4. 4Private subnet

    App and database, out via NAT only

VPC endpoints: skip the internet entirely

Private resources often only need AWS services like S3 or DynamoDB. A VPC endpoint connects to them privately, without going through a NAT gateway.

  • Gateway endpoints (S3, DynamoDB): free, and added as a route.
  • Interface endpoints (most other services): a private IP in your subnet, billed hourly.
Watch out

NAT gateways are billed per hour and per GB processed. A private app pulling lots of data from S3 through a NAT can get expensive. Add the free S3 gateway endpoint instead.

Key takeaways

  • A subnet is public when its route table points 0.0.0.0/0 at an Internet Gateway.
  • NAT gateways let private resources reach out without being reachable.
  • VPC endpoints reach AWS services privately. Gateway endpoints for S3 and DynamoDB are free.

Check your understanding

Pick an answer to see the explanation.

  1. 1. Private app servers need to download OS updates but must not be reachable from the internet. What do you use?