How do you design a VPC with public and private subnets?
Reviewed by Gurusankar M.
Short Answer
Split into public subnets (route to an Internet Gateway — for load balancers/bastions) and private subnets (no direct internet; outbound via a NAT Gateway — for app servers/DBs). Spread subnets across AZs. Keep databases in private subnets, reachable only from the app tier's Security Group.
On this page
Concept Made Simple
Coffee Chat Question
“How do you design a VPC with public and private subnets?”
Remember It Faster
Mind Map Answer
- Public subnet
- route to IGW — ALB, bastion
- Private subnet
- no inbound internet — app, DB
- NAT Gateway
- private → outbound internet only
- Multi-AZ
- subnets in each AZ
Think Beyond the Expected
What If?
A private-subnet service needs to call an external API but has no internet route — how?
Route its outbound traffic through a NAT Gateway in a public subnet — it gets internet egress without being reachable from the internet. For AWS services specifically (S3/DynamoDB), a VPC endpoint keeps traffic on the AWS network and avoids NAT cost.
Real World
The public/private subnet + NAT + multi-AZ layout is the canonical VPC design; putting databases in private subnets with SG-restricted access is baseline security.
Interviewer's Expectation
Keywords they're listening for:
- public vs private subnets
- IGW vs NAT Gateway
- DBs in private subnets
- multi-AZ subnets
- VPC endpoints
Common Mistakes
- Databases in public subnets
- No NAT for private outbound
- Single-AZ subnets (no HA)
Best Practices
- Private subnets for app/data tiers
- NAT for egress; VPC endpoints for AWS services
- Subnets across multiple AZs
Follow-up Questions
- NAT Gateway vs VPC endpoint for S3 access?
- Why place databases in private subnets?
- How do route tables enforce this?
Continue Learning with AI
Take this question deeper with your favourite AI assistant. Pick a depth, copy the prompt, or open it directly — AI is your learning companion, not a shortcut.
Plain-language foundations
I'm preparing for a software engineering interview and want to understand this from scratch, as a beginner. Topic: VPC (AWS) Interview question: "How do you design a VPC with public and private subnets?" Please: 1. Explain the core idea in simple, plain language, using an everyday analogy. 2. Define any technical terms you use. 3. Walk through one small, concrete example. 4. Finish with a single sentence I can easily remember. Keep the tone friendly and assume I'm new to this topic.
Was this answer helpful?
Affiliate links
Tools for Your Developer Workspace
Equipment for a comfortable, productive setup.
As an Amazon Associate I earn from qualifying purchases.
- MonitorView on Amazon : BenQ EW2790U 27-inch Monitor (opens in a new tab)
BenQ EW2790U 27-inch Monitor
- LaptopView on Amazon : Acer Aspire One Laptop (opens in a new tab)
Acer Aspire One Laptop
- Office ChairView on Amazon : Wakefit Gravita Ergonomic Office Chair (opens in a new tab)
Wakefit Gravita Ergonomic Office Chair