VPC Fundamentals

Summary: Amazon VPC (Virtual Private Cloud) is your own private, isolated network within AWS where you launch resources. It controls IP addressing, routing, and connectivity - both between your own subnets and out to the internet, other VPCs, and on-premises networks.

You should know about:

  • VPC, subnets, internet gateways, and NAT gateways
  • Security groups, Network ACLs (NACL), VPC Flow Logs
  • VPC Peering, VPC Endpoints
  • Site-to-Site VPN and Direct Connect

VPC and Subnets

  • VPC - a private network for your resources; scoped to a Region
  • Subnet - partitions a VPC’s network; scoped to a single Availability Zone
  • Public subnet - accessible from the internet (has a route to an Internet Gateway)
  • Private subnet - not accessible from the internet
  • Route tables define how traffic flows between subnets and to/from the internet - each subnet is associated with one route table, and the routes in it determine whether that subnet is effectively public or private

VPC subnets across public and private tiers

VPC Diagram

A VPC is defined by a CIDR range (e.g. 10.0.0.0/16) and spans an entire Region, but each subnet inside it lives in one AZ. A common pattern is to create a public and a private subnet in each AZ, so the architecture stays highly available if one AZ goes down.

VPC spanning two Availability Zones, each with a public and private subnet

Internet Gateway and NAT Gateways

  • Internet Gateway (IGW) - attached at the VPC level, lets VPC resources connect to the internet
  • Public subnets have a route table entry pointing to the IGW
  • NAT Gateway (AWS-managed) / NAT instance (self-managed) - sits in a public subnet and lets instances in private subnets initiate outbound internet connections while remaining unreachable from the internet

Internet gateway and NAT gateway routing outbound traffic from private subnets

Network ACL & Security Groups

Network ACL (NACL)Security Group
Operates atSubnet levelENI / EC2 instance level
Rule typesALLOW and DENYALLOW only
StateStateless - return traffic must be explicitly allowedStateful - return traffic is automatically allowed
Rules can referenceIP addresses onlyIP addresses and other security groups

NACL vs. Security Group statefulness is a classic exam trap: a security group automatically allows response traffic, but a NACL does not - you must explicitly allow both inbound and outbound.

Network ACL as a subnet-level firewall vs. security groups at the instance level

VPC Flow Logs

Capture metadata about IP traffic going into your interfaces, at three levels:

  • VPC Flow Logs
  • Subnet Flow Logs
  • Elastic Network Interface (ENI) Flow Logs

Useful for monitoring and troubleshooting connectivity issues, e.g.:

  • Subnet to internet

  • Internet to subnet

  • Subnet to subnet

  • Also captures traffic from AWS-managed interfaces: ELB, ElastiCache, RDS, Aurora, etc.

  • Destinations: S3, CloudWatch Logs, Kinesis Data Firehose

VPC Peering

Connects two VPCs privately over AWS’s network so they behave as if they were on the same network.

  • CIDR ranges of the two VPCs must not overlap
  • Not transitive - a peering connection must be established explicitly between every pair of VPCs that need to communicate

Non-transitivity is the key exam trap for VPC Peering: if A↔B and B↔C are peered, A and C still cannot communicate unless you also create an A↔C peering connection.

Three VPCs each requiring their own direct peering connection - A↔B, A↔C, B↔C

VPC Endpoints

Let you connect to AWS services using AWS’s private network instead of the public internet - lower latency, better security, and traffic never leaves the AWS network. Only usable from within your VPC.

VPC Endpoint GatewayVPC Endpoint Interface
MechanismTarget in a route tableENI with a private IP in your subnet
Supported servicesS3 and DynamoDB onlyMost AWS services (including S3 and DynamoDB)

VPC endpoints: interface (ENI-based) vs. gateway (route table-based) access to S3, DynamoDB, and CloudWatch

Site-to-Site VPN and Direct Connect

Site-to-Site VPNDirect Connect (DX)
ConnectsOn-premises to AWSOn-premises to AWS
Network pathPublic internetPrivate physical connection
EncryptionAutomaticNot automatic (private, but you add encryption if needed)
Setup timeMinutesAt least a month
Security/speedGoodPrivate, secure, and fast

Site-to-Site VPN over the public internet vs. Direct Connect's private physical link

Typical 3-Tier Solution Architecture

A common pattern combining the pieces above:

  • Route 53 resolves the domain and directs users to the entry point
  • Public subnets hold a Multi-AZ ELB as the entry point
  • Private subnets (one per AZ) hold the app tier - EC2 instances in an Auto Scaling Group
  • Data subnet holds RDS (read/write data) and ElastiCache (session/cached data)

Route 53 and ELB in public subnets, an Auto Scaling Group in private subnets, and RDS/ElastiCache in a data subnet

LAMP Stack on EC2

  • Linux - OS for EC2 instances
  • Apache - web server running on Linux (EC2)
  • MySQL - database on RDS
  • PHP - application logic (running on EC2)

Can add Redis/Memcached (ElastiCache) for caching. Application data and software are typically stored on the root EBS volume.

Other popular stacks worth recognizing: MEAN/MERN (MongoDB, Express, Angular/React, Node), Django (Python + Postgres), Ruby on Rails, and JAMstack (static frontend + APIs, e.g. S3/CloudFront + Lambda).

Configuration & Limits

  • VPC: regional resource, defined by a CIDR range
  • Subnet: AZ-scoped resource, partitions a VPC
  • VPC Peering: CIDR ranges must not overlap

Exam Tips & Gotchas

  • NACLs are stateless (must allow inbound and outbound explicitly); Security Groups are stateful (return traffic auto-allowed)
  • VPC Peering is not transitive - each pair of VPCs needs its own peering connection
  • VPC Endpoint Gateway only supports S3 and DynamoDB; Endpoint Interface supports most other services
  • Direct Connect takes at least a month to provision - not suitable for urgent connectivity needs
  • Site-to-Site VPN is quick to set up but travels over the public internet (encrypted); Direct Connect is private but slow to provision

Integrations

  • EC2 - instances are launched into VPC subnets and secured with security groups
  • RDS, Aurora, ElastiCache - typically placed in private/data subnets, reachable via VPC endpoints or peering
  • ELB - sits in public subnets as the entry point for a 3-tier architecture
  • Route 53 - resolves domain names to the entry point (e.g. an ELB) of a VPC-based architecture

Review Questions