- Ask: should devices on the internet be able to directly reach the resources in this subnet?
- If yes → make the subnet public.
- If no → make the subnet private.
Public subnets host resources that must be reachable from the internet (for example, web servers or load balancers). Private subnets host resources that should not be directly reachable (for example, databases, caches, or backend services). Control access using route tables, NAT gateways/instances, security groups, and network ACLs.
Example: simple web application (public + private)
Consider a typical web application:- The web server serves users on the internet → belongs in a public subnet (has route to an Internet Gateway and usually a public IP or sits behind a public ELB).
- The database should not be exposed to the internet → belongs in a private subnet (no direct route to the Internet Gateway; only accessible from the web server or other allowed resources).

- Internet → (Internet Gateway) → public subnet → web server.
- Web server (in public subnet) → private subnet → database (over private IPs).
- Private subnet typically has no route to the Internet Gateway; outbound internet access (if required for updates, package downloads, etc.) is proxied through a NAT Gateway or NAT instance in a public subnet.
- Allow the web server security group to connect to the database port:
- Create a route for a public subnet to an Internet Gateway:
- Create a route for a private subnet to a NAT Gateway for controlled outbound access:
Extending an on-premises network into AWS
When you extend a private data center into AWS (via VPN or Direct Connect), you commonly place those workload servers in private subnets because they are accessed from your private network rather than the public internet.
- On-premises network ↔ VPN/Direct Connect ↔ VPC private subnets
- No Internet Gateway route in the private subnet’s route table (internet access can still be provided via NAT if needed)
- Security groups and route tables restrict exposure to only the required internal sources
Do not expose databases, admin panels, or sensitive management interfaces directly in public subnets. Always restrict access via security groups and consider bastion hosts (jump boxes) or VPN access for administrative access.
Quick reference: public vs private subnet
Best practices & checklist
- Place internet-facing services in public subnets (or behind public load balancers).
- Place databases and sensitive services in private subnets.
- Use security groups to allow only the minimum required traffic (e.g., allow DB port only from the web server SG).
- Use NAT Gateways in public subnets to provide controlled outbound internet access for private subnets.
- Use VPN or Direct Connect for private connectivity from on-premises datacenters.
- Consider VPC endpoints for AWS service access from private subnets without using the internet.
Links and references
- AWS VPC documentation
- Amazon VPC subnets
- NAT gateways
- Security groups for your VPC
- AWS Direct Connect
- AWS VPN documentation
- AWS CLI reference
- Public subnets host resources that must be reachable from the internet (they have a route to an Internet Gateway and usually public IP addresses).
- Private subnets host resources that should not be directly reachable from the internet (they lack a direct route to an Internet Gateway and typically use private IP addresses and NAT for outbound access).