Virtual Private Cloud — Networking & Content Delivery
/28 (16 IPs) to max /16 (65,536 IPs).Only private IP ranges are allowed in a VPC: 10.0.0.0/8, 172.16.0.0/12, 192.168.0.0/16.
| Feature | Public Subnet | Private Subnet |
|---|---|---|
| Internet Access | Yes, via Internet Gateway | No direct internet access |
| Route Table | Route to Internet Gateway (0.0.0.0/0 → IGW) | Route to NAT Gateway for outbound (0.0.0.0/0 → NAT) |
| Use Cases | Web servers, load balancers, bastion hosts | Databases, application servers, backend services |
| Public IP | Instances can have public IPs | Instances only have private IPs |
A subnet is public if its route table has a route to an Internet Gateway. A subnet is private if it does not.
Both allow instances in private subnets to access the internet for updates, patches, etc., while remaining unreachable from the internet.
| Feature | NAT Gateway | NAT Instance |
|---|---|---|
| Managed by | AWS (fully managed) | You (self-managed EC2) |
| Availability | Highly available within AZ (create in each AZ for multi-AZ HA) | Use scripts to manage failover |
| Bandwidth | Up to 100 Gbps | Depends on EC2 instance type |
| Cost | Pay per hour + data processed | Pay per EC2 hour + data, type, size |
| Security Groups | Cannot be associated | Can be associated |
| Bastion Host | Cannot be used as one | Can be used as bastion host |
| Source/Dest Check | N/A | Must be disabled |
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.
| Feature | Security Groups | Network ACLs (NACLs) |
|---|---|---|
| Level | Instance level (ENI) | Subnet level |
| State | Stateful — return traffic automatically allowed | Stateless — return traffic must be explicitly allowed |
| Rules | Allow rules only | Allow and Deny rules |
| Rule Evaluation | All rules evaluated before deciding | Rules evaluated in order (lowest number first) |
| Default | Default SG: denies all inbound, allows all outbound | Default NACL: allows all inbound and outbound |
| Applies to | Only if associated with an instance | Automatically applies to all instances in the subnet |
| Reference other SGs | Yes (can reference other security groups) | No (only CIDR ranges) |
Security Groups = stateful + allow only. NACLs = stateless + allow & deny. This is a very common exam question.
VPC Flow Logs capture network traffic metadata. They are used for troubleshooting and security analysis. GuardDuty analyzes them for threat detection.
VPC Peering is non-transitive. For connecting many VPCs in a hub-and-spoke model, use Transit Gateway instead.
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 Endpoint = S3 & DynamoDB (free). Interface Endpoint = most other services (paid, uses PrivateLink). Both keep traffic private within AWS.
If the exam asks how to expose a service to hundreds or thousands of VPCs securely, the answer is AWS PrivateLink.
| Feature | Site-to-Site VPN | Direct Connect |
|---|---|---|
| Connection | Over public internet (encrypted) | Dedicated private connection |
| Setup Time | Minutes | 1+ month |
| Cost | Lower | Higher |
| Bandwidth | Limited by internet | Up to 100 Gbps |
| Latency | Variable | Consistent & low |
| Encryption | Yes (IPSec) | Not by default |
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.
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.