← Back to Home

Amazon VPC

Virtual Private Cloud — Networking & Content Delivery

VPC Overview

Key Point:

Only private IP ranges are allowed in a VPC: 10.0.0.0/8, 172.16.0.0/12, 192.168.0.0/16.

Subnets

Public Subnet vs Private Subnet

FeaturePublic SubnetPrivate Subnet
Internet AccessYes, via Internet GatewayNo direct internet access
Route TableRoute to Internet Gateway (0.0.0.0/0 → IGW)Route to NAT Gateway for outbound (0.0.0.0/0 → NAT)
Use CasesWeb servers, load balancers, bastion hostsDatabases, application servers, backend services
Public IPInstances can have public IPsInstances only have private IPs
Exam Tip:

A subnet is public if its route table has a route to an Internet Gateway. A subnet is private if it does not.

Internet Gateway (IGW)

NAT Gateway vs NAT Instance

Both allow instances in private subnets to access the internet for updates, patches, etc., while remaining unreachable from the internet.

FeatureNAT GatewayNAT Instance
Managed byAWS (fully managed)You (self-managed EC2)
AvailabilityHighly available within AZ (create in each AZ for multi-AZ HA)Use scripts to manage failover
BandwidthUp to 100 GbpsDepends on EC2 instance type
CostPay per hour + data processedPay per EC2 hour + data, type, size
Security GroupsCannot be associatedCan be associated
Bastion HostCannot be used as oneCan be used as bastion host
Source/Dest CheckN/AMust be disabled
Exam Tip:

NAT Gateway is the AWS-recommended solution. NAT Instance is a legacy approach. NAT Gateway must be placed in a public subnet and needs an Elastic IP.

Security Groups vs NACLs

FeatureSecurity GroupsNetwork ACLs (NACLs)
LevelInstance level (ENI)Subnet level
StateStateful — return traffic automatically allowedStateless — return traffic must be explicitly allowed
RulesAllow rules onlyAllow and Deny rules
Rule EvaluationAll rules evaluated before decidingRules evaluated in order (lowest number first)
DefaultDefault SG: denies all inbound, allows all outboundDefault NACL: allows all inbound and outbound
Applies toOnly if associated with an instanceAutomatically applies to all instances in the subnet
Reference other SGsYes (can reference other security groups)No (only CIDR ranges)
Key Point:

Security Groups = stateful + allow only. NACLs = stateless + allow & deny. This is a very common exam question.

VPC Flow Logs

Exam Tip:

VPC Flow Logs capture network traffic metadata. They are used for troubleshooting and security analysis. GuardDuty analyzes them for threat detection.

VPC Peering

Exam Tip:

VPC Peering is non-transitive. For connecting many VPCs in a hub-and-spoke model, use Transit Gateway instead.

VPC Endpoints

Allow you to connect to AWS services using a private network instead of the public internet. This removes the need for an IGW or NAT to access supported AWS services.

Gateway Endpoints

Interface Endpoints (powered by AWS PrivateLink)

Key Point:

Gateway Endpoint = S3 & DynamoDB (free). Interface Endpoint = most other services (paid, uses PrivateLink). Both keep traffic private within AWS.

AWS PrivateLink (VPC Endpoint Services)

Exam Tip:

If the exam asks how to expose a service to hundreds or thousands of VPCs securely, the answer is AWS PrivateLink.

Hybrid Connectivity: On-Premises to AWS

Site-to-Site VPN

AWS Direct Connect

AWS Client VPN

FeatureSite-to-Site VPNDirect Connect
ConnectionOver public internet (encrypted)Dedicated private connection
Setup TimeMinutes1+ month
CostLowerHigher
BandwidthLimited by internetUp to 100 Gbps
LatencyVariableConsistent & low
EncryptionYes (IPSec)Not by default
Exam Tip:

Direct Connect = private, dedicated, 1+ month setup. Site-to-Site VPN = encrypted, public internet, fast setup. If the question mentions "quick" or "immediately," choose VPN. If it mentions "dedicated" or "consistent," choose Direct Connect.

AWS Transit Gateway

Key Point:

Transit Gateway is the go-to solution for connecting many VPCs and on-premises networks through a single, centralized hub. It solves the non-transitive limitation of VPC Peering.