Opscraft
AWS core services · Lesson 1 of 8 · 6 min read

VPC design

Almost every Bangalore Senior DevOps JD says "strong AWS". The EKS and Route 53 topics cover two corners; this topic fills in the rest that interviewers probe: VPC design and connectivity, EC2 and Auto Scaling, load balancers, S3/EBS/EFS, RDS/Aurora/DynamoDB basics, CloudFormation in depth, Secrets Manager/SSM, and the high-availability, disaster recovery and cost decisions a senior engineer is expected to make. IAM has its own topic.

Building blocks

Enlarge diagramAWS ACCOUNTREGION AP-SOUTH-1 (MUMBAI)VPC 10.20.0.0/16AZ AP-SOUTH-1AAZ AP-SOUTH-1BAZ AP-SOUTH-1Cpublic subnetprivate subnetpublic subnetprivate subnetpublic subnetprivate subnet
Figure 1. How the AWS building blocks nest: an account holds regions, a region holds Availability Zones, and a VPC spans the zones while each subnet lives in exactly one.
Swipe sideways to see all of it, or tap to open it full screen.
Component What it does
VPC Your private network in a region, with one or more IPv4 CIDRs (/16 to /28) and optional IPv6
Subnet A CIDR slice in one Availability Zone; public or private depending on its route table. AWS reserves 5 IPs per subnet (network, router, DNS, future, broadcast)
Route table Per subnet; the most specific route wins (longest prefix match)
Internet Gateway (IGW) Two-way internet access for resources with public IPs in public subnets
NAT Gateway Outbound-only internet for private subnets. The classic zonal NAT gateway lives in one public subnet — place one per AZ for HA and to avoid cross-AZ charges. Since November 2025 you can instead create a regional NAT gateway, which spans the VPC's AZs automatically and needs no public subnet
Egress-only IGW Outbound-only for IPv6
Security Group Stateful firewall on ENIs; allow rules only; can reference other SGs
Network ACL Stateless subnet-level firewall; allow and deny rules, numbered, evaluated in order; return traffic (ephemeral ports 1024–65535) must be allowed explicitly
VPC endpoints Private access to AWS services: Gateway endpoints (S3, DynamoDB — free, route-table based) and Interface endpoints (PrivateLink ENIs — ECR, STS, Secrets Manager, CloudWatch... hourly + data cost)
VPC Flow Logs Accept/reject metadata for ENIs/subnets/VPC to CloudWatch Logs or S3

A standard three-tier layout

Enlarge diagrampublic /24ALB, NAT gatewaypublic /24ALB, NAT gatewaypublic /24ALB, NAT gatewayprivate /19EKS nodes and podsprivate /19EKS nodes and podsprivate /19EKS nodes and podsdata /22RDS, ElastiCachedata /22RDS, ElastiCachedata /22RDS, ElastiCachepublicprivatedataAZ aAZ bAZ cRoutes: public → internet gateway · private → NAT in the same AZ · data → no internet route
Figure 2. The standard three-tier layout across three AZs. Private subnets are sized large because every EKS pod takes a VPC IP.
Swipe sideways to see all of it, or tap to open it full screen.

Public subnets 10.20.0.0/24–10.20.2.0/24 hold ALBs and NAT gateways (route 0.0.0.0/0 → IGW); private subnets 10.20.32.0/19, 10.20.64.0/19, 10.20.96.0/19 hold EKS nodes, pods and EC2 (0.0.0.0/0 → the NAT gateway in the same AZ); data subnets 10.20.128.0/22 ×3 hold RDS and ElastiCache with no internet route.

Design points interviewers like:

  • Size for EKS — with the VPC CNI every pod gets a VPC IP; give private subnets /19 or larger, or use prefix delegation / secondary CIDRs (100.64.0.0/10 custom networking) when IPs run out.
  • Non-overlapping CIDRs across VPCs and on-prem, planned centrally (IPAM) — overlap blocks peering and Transit Gateway routing.
  • Gateway endpoints for S3/DynamoDB and interface endpoints for ECR/STS/logs cut NAT data-processing cost and keep traffic private.
  • SG references (allow from the ALB's SG to the app's SG) instead of CIDRs.

Security groups vs NACLs

Security group NACL
Level ENI (instance/pod/ALB) Subnet
State Stateful — return traffic allowed automatically Stateless — both directions needed
Rules Allow only Allow and deny, ordered by number, first match wins
Default New SG: deny all inbound, allow all outbound Default NACL allows all; custom NACL denies all until rules are added
Typical use Primary control Coarse subnet guardrails, blocking specific CIDRs

Connecting VPCs and on-prem

Option Use Notes
VPC peering Few VPCs Non-transitive, no overlapping CIDRs, routes on both sides
Transit Gateway Hub-and-spoke for many VPCs, VPN and Direct Connect Transitive routing with route tables per attachment; cross-account via RAM; per-attachment and data charges
PrivateLink Expose one service to other VPCs/accounts Consumer gets an interface endpoint; works with overlapping CIDRs; one-directional
Site-to-Site VPN Encrypted tunnels over internet to on-prem Two tunnels per connection for HA; quick to set up
Direct Connect Dedicated private link to on-prem Consistent bandwidth/latency; pair with VPN or second DX for resilience

Troubleshooting connectivity — the checklist

Instance A can't reach B on port 5432:

  1. Security groups — B's inbound allows the port from A's SG/CIDR? A's outbound allows it?
  2. NACLs on both subnets — inbound and outbound, including ephemeral return ports.
  3. Route tables — is there a route to the destination (peering/TGW/NAT/IGW) in both directions?
  4. DNS — does the name resolve to the private IP (Route 53 private zones, enableDnsHostnames/enableDnsSupport)?
  5. Host-level — is the service listening on that interface; OS firewall.
  6. Reachability Analyzer checks the path configuration; Flow Logs show ACCEPT/REJECT on the ENIs.
Enlarge diagramSecurity groupsB's inbound allows A's SGNACLsboth subnets, both directionsRoute tablesa route each wayDNSname resolves to the private IPHostlistening on that interfaceProve itReachability Analyzer, FlowLogs123456
Figure 3. Instance A cannot reach instance B on port 5432: check each layer in order.
Swipe sideways to see all of it, or tap to open it full screen.