📡 You're offline — showing cached content
New version available!
Quick Access
Tutorials AWS Solutions Architect VPC — Virtual Private Cloud

VPC — Virtual Private Cloud

6 min read Quiz at the end
Design secure VPCs with public, private, and database subnets. Master Security Groups, NACLs, NAT Gateways, and VPC connectivity options.

VPC — Your Private Network in AWS

A VPC is your own private, isolated section of the AWS cloud. Think of it as your own personal data center network inside AWS — you control the IP addresses, subnets, routing, and security rules.

Teacher Note: Imagine VPC is like your office building. Public subnets are the reception and lobby (anyone can access). Private subnets are the offices and server rooms (only employees can enter). Database subnets are the vault (only specific servers can reach it).

Three-Tier Architecture — The Standard Design

Internet
    |
[Internet Gateway]
    |
+--Public Subnet (ALB, NAT Gateway)--+
    |
+--Private Subnet (EC2, ECS, Lambda)--+
    |
+--Database Subnet (RDS, ElastiCache)--+

Key VPC Components

ComponentPurposeKey Fact
Internet Gateway (IGW)Allows internet traffic IN and OUT for public subnetsOne per VPC, bidirectional
NAT GatewayLets private subnets reach internet (outbound only)Deploy one per AZ for HA
Security GroupsInstance-level stateful firewall — Allow rules onlyReturn traffic auto-allowed
NACLsSubnet-level stateless firewall — Allow AND Deny rulesMust allow ephemeral ports for return traffic
Route TablesControl where traffic flows between subnetsEach subnet needs one
VPC EndpointsAccess AWS services (S3, DynamoDB) without internetFREE for Gateway type

Security Groups vs NACLs

FeatureSecurity GroupNACL
LevelInstance (EC2, RDS)Subnet
StateStateful — return traffic auto-allowedStateless — must allow both directions
RulesAllow onlyAllow AND Deny
OrderAll rules evaluatedRules evaluated in number order
Use casePrimary access controlBlock specific IPs, additional layer

Connecting VPCs and Networks

  • VPC Peering: direct connection between two VPCs — NOT transitive (A-B-C does not mean A can reach C)
  • Transit Gateway: hub-and-spoke for many VPCs — solves the transitive peering limitation
  • Site-to-Site VPN: encrypted tunnel over internet to on-premises — quick to set up
  • Direct Connect: dedicated private line to AWS — consistent latency, expensive, 1-3 months to provision
  • PrivateLink: expose your service to other VPCs privately without peering or public internet
Exam Tip: Most common exam trap: Security Groups are STATEFUL (return traffic auto-allowed). NACLs are STATELESS (you must add rules for BOTH directions including ephemeral ports 1024-65535 for TCP responses).
Topic Quiz · 3 questions

Test your understanding before moving on

1. A web application in a private subnet needs to download software updates from the internet. Which component enables this WITHOUT exposing the instance to inbound internet traffic?
💡 A NAT Gateway allows private subnet instances to initiate outbound internet connections but blocks all inbound connections from the internet.
2. A security team wants to block all traffic from a specific malicious IP address range from reaching ANY instance in a subnet. What is the correct tool?
💡 NACLs support explicit Deny rules at the subnet level. Security Groups only support Allow rules.
3. Company A's VPC is peered with Company B's VPC. Company B's VPC is peered with Company C's VPC. Can Company A access Company C's VPC?
💡 VPC peering is not transitive. Company A needs a direct peering connection to Company C's VPC to communicate.