Core VPC Components
| Component | Description |
|---|---|
| VPC | The root container for all AWS networking resources |
| Subnet | Logical segmentation within a VPC (public or private) |
| Route Table | Defines how traffic is directed within or outside the VPC |
| Internet Gateway (IGW) | Enables Internet access for public subnets |
| NAT Gateway (NATGW) | Enables private subnets to initiate outbound traffic securely |
| Network ACL (NACL) | Stateless packet filter applied at subnet level |
| Security Group (SG) | Stateful firewall applied to instances/ENIs |
| VPC Peering / Transit Gateway | Connects multiple VPCs or hybrid networks |
Default vs Custom VPCs
- Default VPC
- Custom VPC
Automatically created per region
- One public subnet per AZ
- Internet access enabled
- Auto-created security group and route table
- Good for testing or quick labs
VPC CIDR and Subnetting
Each VPC is assigned an IPv4 CIDR block (and optionally IPv6). AWS allows between /16 and /28 for the VPC’s CIDR range.Example Architecture
| Subnet | CIDR | AZ | Type | Route Table | Internet Access |
|---|---|---|---|---|---|
| Public-A | 10.0.1.0/24 | eu-west-2a | Public | Public RT | ✅ |
| Private-A | 10.0.2.0/24 | eu-west-2a | Private | Private RT | ❌ |
| Private-B | 10.0.3.0/24 | eu-west-2b | Private | Private RT | ❌ |
Each subnet resides entirely within one Availability Zone.
VPC Architecture Overview
Public Subnet
Contains resources needing Internet access (e.g. bastion hosts, web servers)
Private Subnet
Isolated, no direct inbound access (e.g. databases, backend apps)
NAT Gateway
Allows outbound Internet access from private subnets
Internet Gateway
Allows inbound/outbound Internet for public subnets
Route Table Behaviour
| Destination | Target | Description |
|---|---|---|
10.0.0.0/16 | local | Enables internal VPC communication |
0.0.0.0/0 | igw-xxxxxx | Internet access for public subnets |
0.0.0.0/0 | nat-xxxxxx | Outbound Internet via NATGW for private subnets |
Each subnet can be associated with only one route table, but a route table can be associated with multiple subnets.
Security Model: NACL vs Security Groups
| Feature | Network ACL (NACL) | Security Group (SG) |
|---|---|---|
| Type | Stateless | Stateful |
| Scope | Subnet-level | Instance/ENI-level |
| Rules Evaluated | Inbound + Outbound | Inbound + Outbound |
| Default Behaviour | Deny all (custom) / Allow all (default) | Deny all inbound, allow all outbound |
| Use Case | Granular subnet filtering | Instance-level firewalling |
Common AWS CLI Commands
- VPC Management
- Subnet Management
- Route Tables
- Security Groups
Lab Exercise
Configure Route Tables
Create route tables for public and private subnets:
- Public → IGW for Internet
- Private → NAT Gateway for outbound Internet
Integration with On-Prem / Multi-VPC
AWS supports multiple interconnect options:| Connection Type | Description | Routing Type |
|---|---|---|
| VPC Peering | Point-to-point connection between VPCs | Static routes |
| Transit Gateway (TGW) | Central hub for multi-VPC or hybrid connectivity | Dynamic (BGP optional) |
| VPN / Direct Connect | Connect on-premises networks | Static or BGP dynamic routing |
Security Best Practices
Use Custom VPCs
Disable default VPCs in production environments
Restrict Security Groups
Change default security groups — restrict inbound access
Separate Environments
Separate Prod/Dev/Test into different VPCs
Least Privilege
Enforce least privilege routing and network isolation
Enable Flow Logs
Use VPC Flow Logs for visibility and auditing
Tag Resources
Tag all network components consistently