Medium👤 3-5 years👤 8-15 years 1 min read

How do you design a VPC with public and private subnets?

Asked inAmazonMicrosoftDeloitte
#vpc#subnets#nat gateway#internet gateway#network design
Report issue

⚡ 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.

Coffee Chat Question

Concept Made Simple

How do you design a VPC with public and private subnets?

🧠Mind Map Answer

Remember It Faster

Public subnetroute to IGW — ALB, bastion
Private subnetno inbound internet — app, DB
NAT Gatewayprivate → outbound internet only
Multi-AZsubnets in each AZ

🔥What If?

Think Beyond the Expected

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 subnetsIGW vs NAT GatewayDBs in private subnetsmulti-AZ subnetsVPC 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

  • 1NAT Gateway vs VPC endpoint for S3 access?
  • 2Why place databases in private subnets?
  • 3How do route tables enforce this?

🧩Related Technologies

NAT GatewayInternet GatewayVPC endpointsroute tables

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.
Open inChatGPTGeminiClaude

Was this answer helpful?

Support our platform by exploring our recommended products.

As an Amazon affiliate, purchases through these links may earn us a small commission — at no extra cost to you. It helps keep Full Stack Interview Guru free.

Related Questions