Master AWS VPC Fundamentals and Network Design: Build a Rock-Solid Cloud Network 2025
Reading Time: 40 minutes | Difficulty: Beginner to Intermediate | Last Updated: 29 November 2025
Table of Contents: AWS VPC Fundamentals
TL;DR: AWS VPC Fundamentals
- Amazon VPC provides isolated network environment with complete control over IP addressing, subnets, and routing
- Public subnets have direct internet access via Internet Gateway, private subnets use NAT Gateway for outbound-only access
- CIDR block planning is critical – use /16 for VPC and /24 for subnets to allow future growth
- Security Groups act as instance-level firewalls, NACLs provide subnet-level network filtering with rule priority
- Transit Gateway scales better than VPC peering for multi-VPC architectures (linear vs n² connections)
- VPC Endpoints reduce NAT Gateway costs for S3/DynamoDB traffic above 2.5TB/month
- Essential for 26% of SAA-C03 exam covering resilient architectures and network security
- Free tier covers most components – excludes NAT Gateway, VPN connections, and cross-AZ data transfer
Introduction: AWS VPC Fundamentals and Network Design
Picture this: You’re the lead architect at a rapidly growing fintech startup. Your CEO just announced plans to expand into three new countries, your user base is growing 300% quarterly, and compliance requirements are getting stricter. Your current “throw everything in the default VPC” approach just hit a wall when security auditors flagged your flat network design as a critical risk.
Sound familiar? This is exactly why mastering Amazon VPC (Virtual Private Cloud) is non-negotiable for any serious AWS professional. VPC isn’t just about creating networks—it’s about building the secure, scalable foundation that enables everything else in your AWS architecture.
What we’ll learn today: AWS VPC Fundamentals
- How to design and implement production-ready VPC architectures from scratch
- Master subnet design patterns for multi-tier applications and compliance requirements
- Configure routing, security groups, and NACLs for defense-in-depth security
- Apply AWS networking best practices that scale from startup to enterprise
Why this matters: VPC fundamentals directly impact security, cost, performance, and compliance across your entire AWS infrastructure. Companies like Netflix and Airbnb process billions of requests daily through carefully architected VPC designs that we’ll explore today.
SAA-C03 relevance: VPC topics account for approximately 15% of the exam across multiple domains, with heavy emphasis on security group vs NACL scenarios, subnet design decisions, and routing troubleshooting.
Prerequisites
AWS account requirements:
- Active AWS account with administrative access
- AWS CLI v2 configured with programmatic access
- Basic understanding of IP addressing and subnetting
Prior knowledge required:
- TCP/IP networking fundamentals (IP addresses, subnets, routing)
- Basic security concepts (firewalls, access control lists)
- EC2 instance management from our previous posts
Tools required:
- Web browser for AWS Console access
- Text editor for YAML/JSON configurations
- Calculator for CIDR subnet planning
Estimated time: 45-60 minutes for complete walkthrough Cost estimate: $0.00 – All VPC components covered are free tier eligible
📌 Quick Refresher: Remember that AWS provides a default VPC in each region, but production workloads require custom VPC design for security, compliance, and scalability requirements.
Step-by-Step Tutorial
Theory First: Understanding VPC Architecture
Amazon VPC is your private section of the AWS cloud where you have complete control over your virtual networking environment. Think of it as renting an entire floor of a skyscraper where you can design the layout, install security systems, and control who has access to what rooms.
Core VPC Components:
- VPC: The virtual network itself, defined by a CIDR block (e.g., 10.0.0.0/16)
- Subnets: Subdivisions of your VPC CIDR block, always within a single Availability Zone
- Internet Gateway: Enables internet access for resources in public subnets
- Route Tables: Define where network traffic is directed
- Security Groups: Stateful firewalls at the instance level
- NACLs: Stateless firewalls at the subnet level
Service Positioning: VPC sits at the foundation of AWS networking, supporting EC2, RDS, Lambda, EKS, and virtually every other AWS service that needs network connectivity.
Service Limits to Know:
- 5 VPCs per region (soft limit, can request increase)
- 200 subnets per VPC
- 5 security groups per network interface
- 20 rules per security group (inbound/outbound counted separately)
ARCHITECTURE DIAGRAM:

Console Walkthrough: Building Production-Ready VPC
Let’s build a production-ready VPC architecture that supports a typical 3-tier web application with high availability across multiple Availability Zones.
Step 1: Create the VPC Foundation
- Navigate to VPC Console:
- Open AWS Console → Services → VPC
- Click “Create VPC” (not “Launch VPC Wizard” – we’re doing this properly)
[SCREENSHOT: VPC Console main dashboard showing “Create VPC” button]
- Configure VPC Settings:
Name tag: Production-VPC-us-east-1IPv4 CIDR block: 10.0.0.0/16IPv6 CIDR block: No IPv6 CIDR blockTenancy: Default
💡 Pro Tip: Use 10.0.0.0/16 for production VPCs – it provides 65,536 IP addresses and follows RFC 1918 private address standards. Avoid 192.168.x.x which often conflicts with home/office networks.
- Verify VPC Creation:
- Note the VPC ID (vpc-xxxxxxxx) – you’ll reference this throughout the setup
- Confirm Default Security Group and NACL were automatically created
- Check that Main Route Table was generated
⚠️ Console Evolution Notice: AWS continuously updates the console interface. The core functionality remains the same, but button locations may vary.
Step 2:
How to Create Subnets in AWS for High Availability?
Subnet Strategy for High Availability:
- Public subnets: Web servers, load balancers, NAT Gateways
- Private subnets: Application servers, databases
- Database subnets: Isolated database tier (optional but recommended)
CIDR Planning with Accurate Calculations:
| Tier | us-east-1a | us-east-1b |
|---|---|---|
| Public | 10.0.1.0/24 | 10.0.2.0/24 |
| Private | 10.0.11.0/24 | 10.0.12.0/24 |
| Database | 10.0.21.0/24 | 10.0.22.0/24 |
VPC CIDR: 10.0.0.0/16 (65,536 total addresses)
Public Subnets:
- us-east-1a: 10.0.1.0/24 (256 total - 5 reserved = 251 usable)
- us-east-1b: 10.0.2.0/24 (256 total - 5 reserved = 251 usable)
Private Subnets:
- us-east-1a: 10.0.11.0/24 (251 usable addresses)
- us-east-1b: 10.0.12.0/24 (251 usable addresses)
Database Subnets:
- us-east-1a: 10.0.21.0/24 (251 usable addresses)
- us-east-1b: 10.0.22.0/24 (251 usable addresses)
IPv6 Dual-Stack (Modern Networks):
- VPC IPv6 CIDR: 2001:db8:1234::/56 (assigned by AWS)
- Public Subnet IPv6: 2001:db8:1234:1a00::/64
- Private Subnet IPv6: 2001:db8:1234:1b00::/64
AWS IP Reservation (Critical for Capacity Planning): AWS reserves exactly 5 IP addresses in every subnet:
- ‘
.0‘- Network address - ‘
.1‘ – VPC router - ‘
.2‘ – DNS server (Amazon-provided DNS) - ‘
.3‘ – Reserved for future use - ‘
.255‘ – Broadcast address (not supported in VPC but reserved)
Example: In subnet 10.0.1.0/24
- Total addresses: 2^(32-24) = 256
- Usable for instances: 256 – 5 = 251
- First usable: 10.0.1.4
- Last usable: 10.0.1.254
- Create Public Subnet 1:
Name tag: Public-Subnet-us-east-1a VPC: [Select your Production VPC] Availability Zone: us-east-1a IPv4 CIDR block: 10.0.1.0/24 - Repeat for all 6 subnets following the CIDR plan above
[SCREENSHOT: Subnet creation form with all fields populated]
🔧 Try This: After creating subnets, use the VPC visual mapper in the console to see your network topology. This helps identify any architectural issues early.
Step 3: Internet Gateway and Public Connectivity
- Create Internet Gateway:
Name tag: Production-IGW - Attach Internet Gateway to VPC:
- Select the Internet Gateway
- Actions → Attach to VPC
- Select your Production VPC
Step 4: Configure Route Tables for Internet Access
- Create Public Route Table:
Name tag: Public-Route-Table VPC: [Production VPC] - Add Internet Route:
- Select Public Route Table → Routes tab → Edit routes
- Add route: Destination: 0.0.0.0/0, Target: [Internet Gateway]
- Associate Public Subnets:
- Subnet Associations tab → Edit subnet associations
- Select both public subnets (10.0.1.0/24 and 10.0.2.0/24)
IPv6 Implementation for Modern Networks
Modern production environments increasingly require IPv6 support. AWS provides native IPv6 support in VPC with automatic assignment from Amazon’s IPv6 address space.
Step 6: Enable IPv6 Support
- Add IPv6 CIDR to VPC:
- VPC Dashboard → Select your VPC → Actions → Edit CIDRs
- Add IPv6 CIDR block → Amazon-provided IPv6 CIDR block
- AWS assigns a /56 block (e.g., 2001:db8:1234::/56)
- Configure IPv6 Subnets:
# Add IPv6 CIDR to public subnet
aws ec2 associate-subnet-cidr-block \
--subnet-id subnet-xxxxxxxx \
--ipv6-cidr-block 2001:db8:1234:1a00::/64
# Enable auto-assign IPv6
aws ec2 modify-subnet-attribute \
--subnet-id subnet-xxxxxxxx \
--assign-ipv6-address-on-creation
- Update Route Tables for IPv6:
# Add IPv6 internet route to public route table
aws ec2 create-route \
--route-table-id rtb-xxxxxxxx \
--destination-ipv6-cidr-block ::/0 \
--gateway-id igw-xxxxxxxx
# Add IPv6 NAT route for private subnets (requires Egress-Only Internet Gateway)
aws ec2 create-egress-only-internet-gateway --vpc-id vpc-xxxxxxxx
IPv6 Security Considerations:
- IPv6 addresses are globally routable by default
- Use Security Groups and NACLs to control IPv6 traffic
- Consider IPv6-specific firewall rules for applications
Security Group Chaining Deep Dive
Security Group chaining creates layered security by allowing traffic flow through specific security groups rather than CIDR blocks. This creates dynamic, scalable security policies.
Production Security Group Architecture
# Web Tier Security Group
aws ec2 create-security-group \
--group-name "web-tier-sg" \
--description "Load balancers and web servers" \
--vpc-id vpc-xxxxxxxx
# Allow HTTP/HTTPS from anywhere
aws ec2 authorize-security-group-ingress \
--group-id sg-web-tier \
--protocol tcp \
--port 80 \
--cidr 0.0.0.0/0
aws ec2 authorize-security-group-ingress \
--group-id sg-web-tier \
--protocol tcp \
--port 443 \
--cidr 0.0.0.0/0
# Application Tier Security Group
aws ec2 create-security-group \
--group-name "app-tier-sg" \
--description "Application servers" \
--vpc-id vpc-xxxxxxxx
# Allow traffic ONLY from web tier (security group chaining)
aws ec2 authorize-security-group-ingress \
--group-id sg-app-tier \
--protocol tcp \
--port 8080 \
--source-group sg-web-tier
# Database Tier Security Group
aws ec2 create-security-group \
--group-name "db-tier-sg" \
--description "Database servers" \
--vpc-id vpc-xxxxxxxx
# Allow MySQL ONLY from application tier
aws ec2 authorize-security-group-ingress \
--group-id sg-db-tier \
--protocol tcp \
--port 3306 \
--source-group sg-app-tier
Cross-VPC Security Group References: When VPCs are peered, you can reference security groups across VPC boundaries:
# Reference security group from peered VPC
aws ec2 authorize-security-group-ingress \
--group-id sg-12345678 \
--protocol tcp \
--port 443 \
--source-group sg-87654321 \
--group-owner-id 123456789012
❗ Warning: Cross-VPC security group references require active VPC peering. If peering is deleted, security group rules become ineffective.
Transit Gateway Hub-and-Spoke Architecture
For organizations with multiple VPCs, Transit Gateway provides a scalable alternative to mesh VPC peering.
[ARCHITECTURE DIAGRAM: Hub-and-spoke topology with Transit Gateway at center, connected to 6 VPCs including Shared Services VPC, Production VPC, Development VPC, and Customer VPCs]
Cost Comparison: VPC Peering vs Transit Gateway
VPC Peering (Mesh Topology):
- Connections required: n(n-1)/2 where n = number of VPCs
- 5 VPCs = 10 peering connections
- 10 VPCs = 45 peering connections
- Data transfer: $0.01/GB between regions
Transit Gateway (Hub-and-Spoke):
- Connections required: n (linear scaling)
- 5 VPCs = 5 connections
- 10 VPCs = 10 connections
- Hourly charge: $0.05/hour per attachment = $36.50/month
- Data processing: $0.02/GB
Break-even Analysis:
TGW becomes cost-effective with 4+ VPCs requiring full mesh connectivity:
- 4 VPCs: 6 peering connections vs 4 TGW attachments
- Monthly cost: TGW = $146, Peering = $0 (+ data transfer)
- TGW provides simplified routing and management overhead reduction
Transit Gateway Implementation
# Create Transit Gateway
aws ec2 create-transit-gateway \
--description "Hub for multi-VPC connectivity" \
--options DefaultRouteTableAssociation=enable,DefaultRouteTablePropagation=enable \
--tag-specifications 'ResourceType=transit-gateway,Tags=[{Key=Name,Value=Production-TGW}]'
# Attach VPC to Transit Gateway
aws ec2 create-transit-gateway-vpc-attachment \
--transit-gateway-id tgw-xxxxxxxxx \
--vpc-id vpc-xxxxxxxx \
--subnet-ids subnet-xxxxxxxx subnet-yyyyyyyy
# Update VPC route tables to use TGW
aws ec2 create-route \
--route-table-id rtb-xxxxxxxx \
--destination-cidr-block 10.1.0.0/16 \
--transit-gateway-id tgw-xxxxxxxxx
Transit Gateway Route Tables:
# Create custom route table for isolation
aws ec2 create-transit-gateway-route-table --transit-gateway-id tgw-xxxxxxxxx
# Propagate routes selectively
aws ec2 associate-transit-gateway-route-table \
--transit-gateway-attachment-id tgw-attach-xxxxxxxx \
--transit-gateway-route-table-id tgw-rtb-xxxxxxxx
VPC Endpoint Optimization
VPC Endpoints eliminate the need for NAT Gateway traffic to AWS services, reducing costs and improving security.
Gateway Endpoints (S3 and DynamoDB)
# Create S3 Gateway Endpoint (Free)
aws ec2 create-vpc-endpoint \
--vpc-id vpc-xxxxxxxx \
--service-name com.amazonaws.us-east-1.s3 \
--policy-document file://s3-endpoint-policy.json \
--route-table-ids rtb-private-xxxxxxxx
S3 Endpoint Policy Example:
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Principal": "*",
"Action": [
"s3:GetObject",
"s3:PutObject"
],
"Resource": [
"arn:aws:s3:::company-backups/*",
"arn:aws:s3:::company-logs/*"
]
}
]
}
Interface Endpoints (PrivateLink)
# Create Interface Endpoint for EC2 API
aws ec2 create-vpc-endpoint \
--vpc-id vpc-xxxxxxxx \
--service-name com.amazonaws.us-east-1.ec2 \
--route-table-ids rtb-private-xxxxxxxx \
--policy-document file://ec2-endpoint-policy.json \
--security-group-ids sg-vpc-endpoint
Cost Analysis: VPC Endpoints vs NAT Gateway
| Service Access Pattern | NAT Gateway Cost | VPC Endpoint Cost | Break-Even Point |
|---|---|---|---|
| S3 (Gateway Endpoint) | $32.40 + $0.045/GB | $0.00 | Immediate savings |
| DynamoDB (Gateway) | $32.40 + $0.045/GB | $0.00 | Immediate savings |
| EC2 API (Interface) | $32.40 + $0.045/GB | $7.30 + $0.01/GB | ~2.5TB/month |
| Mixed AWS Services | $32.40 + data charges | Multiple endpoints | Calculate per service |
⚡ Cost Alert: Interface Endpoints cost $0.01/hour ($7.30/month) plus data processing. Use for services with high API call volumes or security requirements. 18. Create NAT Gateway: Name: Production-NAT-Gateway Subnet: Public-Subnet-us-east-1a Connectivity type: Public Elastic IP allocation: [Create new EIP]
⚡ Cost Alert: NAT Gateway costs $0.045/hour + data processing charges. For development environments, consider NAT Instances on t3.nano ($0.0052/hour) instead.
- Create Private Route Table:
Name tag: Private-Route-Table VPC: [Production VPC] - Add NAT Gateway Route:
- Routes tab → Edit routes
- Add route: Destination: 0.0.0.0/0, Target: [NAT Gateway]
- Associate Private Subnets:
- Associate all private and database subnets to Private Route Table
CLI/Infrastructure as Code Implementation
AWS CLI VPC Creation:
# Create VPC
aws ec2 create-vpc \
--cidr-block 10.0.0.0/16 \
--tag-specifications 'ResourceType=vpc,Tags=[{Key=Name,Value=Production-VPC-us-east-1}]'
# Create Internet Gateway
aws ec2 create-internet-gateway \
--tag-specifications 'ResourceType=internet-gateway,Tags=[{Key=Name,Value=Production-IGW}]'
# Create subnets
aws ec2 create-subnet \
--vpc-id vpc-xxxxxxxxx \
--cidr-block 10.0.1.0/24 \
--availability-zone us-east-1a \
--tag-specifications 'ResourceType=subnet,Tags=[{Key=Name,Value=Public-Subnet-us-east-1a}]'
CloudFormation Template (Production-Ready):
AWSTemplateFormatVersion: '2010-09-09'
Description: 'Production VPC with public/private subnets across 2 AZs'
Parameters:
VpcCidr:
Type: String
Default: '10.0.0.0/16'
Description: CIDR block for the VPC
Environment:
Type: String
Default: 'production'
AllowedValues: ['development', 'staging', 'production']
Resources:
VPC:
Type: AWS::EC2::VPC
Properties:
CidrBlock: !Ref VpcCidr
EnableDnsHostnames: true
EnableDnsSupport: true
Tags:
- Key: Name
Value: !Sub '${Environment}-vpc'
- Key: Environment
Value: !Ref Environment
InternetGateway:
Type: AWS::EC2::InternetGateway
Properties:
Tags:
- Key: Name
Value: !Sub '${Environment}-igw'
InternetGatewayAttachment:
Type: AWS::EC2::VPCGatewayAttachment
Properties:
InternetGatewayId: !Ref InternetGateway
VpcId: !Ref VPC
PublicSubnet1:
Type: AWS::EC2::Subnet
Properties:
VpcId: !Ref VPC
AvailabilityZone: !Select [0, !GetAZs '']
CidrBlock: !Select [0, !Cidr [!Ref VpcCidr, 6, 8]]
MapPublicIpOnLaunch: true
Tags:
- Key: Name
Value: !Sub '${Environment}-public-subnet-1'
- Key: Type
Value: 'Public'
PrivateSubnet1:
Type: AWS::EC2::Subnet
Properties:
VpcId: !Ref VPC
AvailabilityZone: !Select [0, !GetAZs '']
CidrBlock: !Select [2, !Cidr [!Ref VpcCidr, 6, 8]]
Tags:
- Key: Name
Value: !Sub '${Environment}-private-subnet-1'
- Key: Type
Value: 'Private'
NatGateway1EIP:
Type: AWS::EC2::EIP
DependsOn: InternetGatewayAttachment
Properties:
Domain: vpc
Tags:
- Key: Name
Value: !Sub '${Environment}-nat-gateway-1-eip'
NatGateway1:
Type: AWS::EC2::NatGateway
Properties:
AllocationId: !GetAtt NatGateway1EIP.AllocationId
SubnetId: !Ref PublicSubnet1
Tags:
- Key: Name
Value: !Sub '${Environment}-nat-gateway-1'
Outputs:
VPC:
Description: A reference to the created VPC
Value: !Ref VPC
Export:
Name: !Sub '${Environment}-VPC'
PublicSubnets:
Description: List of public subnets
Value: !Join [",", [!Ref PublicSubnet1]]
Export:
Name: !Sub '${Environment}-PublicSubnets'
Python SDK Example (Boto3):
import boto3
import json
# Initialize EC2 client
ec2 = boto3.client('ec2', region_name='us-east-1')
def create_production_vpc():
"""Create production VPC with proper tagging and configuration"""
# Create VPC
vpc_response = ec2.create_vpc(
CidrBlock='10.0.0.0/16',
TagSpecifications=[
{
'ResourceType': 'vpc',
'Tags': [
{'Key': 'Name', 'Value': 'Production-VPC'},
{'Key': 'Environment', 'Value': 'production'},
{'Key': 'Project', 'Value': 'web-app'},
{'Key': 'Owner', 'Value': 'devops-team'}
]
}
]
)
vpc_id = vpc_response['Vpc']['VpcId']
print(f"Created VPC: {vpc_id}")
# Enable DNS hostnames and support
ec2.modify_vpc_attribute(VpcId=vpc_id, EnableDnsHostnames={'Value': True})
ec2.modify_vpc_attribute(VpcId=vpc_id, EnableDnsSupport={'Value': True})
return vpc_id
# Usage
if __name__ == "__main__":
vpc_id = create_production_vpc()
print(f"VPC {vpc_id} ready for subnet configuration")
Critical Production Insights
⚠️ Production Alert: Never use the default VPC for production workloads. It lacks proper subnet segmentation and security boundaries required for enterprise compliance.
💡 Pro Tip: Always plan CIDR blocks with future growth in mind. Use /16 for VPC (65,536 addresses) and /24 for subnets (256 addresses) to avoid re-architecting as you scale.
💰 Cost Optimization:
- VPC, subnets, route tables, Internet Gateways, and security groups are free
- NAT Gateways cost $32.40/month plus data processing fees
- Consider NAT Instances for development environments to reduce costs
🔒 Security Best Practices:
- Use separate subnets for different application tiers
- Implement least-privilege security group rules
- Enable VPC Flow Logs for security monitoring and compliance
- Never put databases in public subnets
Real-World Scenarios
**Scenario 1: E-commerce Platform Architecture (Scale: 10M+ monthly users)
Company Profile: ShopFast, an online retailer processing $500M annually Challenge: Handle Black Friday traffic spikes while maintaining PCI DSS compliance Requirements: Separate payment processing, customer data isolation, global delivery
VPC Architecture with Transit Gateway:
Hub-and-Spoke Architecture:
├── Transit Gateway (Central Hub)
├── Production VPC: 10.0.0.0/16
│ ├── Public Subnets (ALB, NAT Gateway)
│ ├── Private App Subnets (Web/App Servers)
│ ├── Database Subnets (RDS Multi-AZ)
├── PCI-DSS Compliance VPC: 10.1.0.0/16
│ ├── Isolated payment processing
│ ├── Dedicated HSM integration
├── Shared Services VPC: 10.2.0.0/16
│ ├── Centralized logging (CloudWatch)
│ ├── CI/CD pipeline infrastructure
│ ├── Monitoring and alerting
├── DR VPC (us-west-2): 10.10.0.0/16
│ ├── Cross-region replication target
│ ├── Disaster recovery infrastructure
Security Group Chaining Implementation:
# Internet-facing Load Balancer SG
ALB-SG: Allow 80/443 from 0.0.0.0/0
# Web Tier SG
WEB-SG: Allow 8080 from ALB-SG only
# Application Tier SG
APP-SG: Allow 9000 from WEB-SG only
# Database Tier SG
DB-SG: Allow 3306 from APP-SG only
# PCI Processing SG (Isolated)
PCI-SG: Allow 8443 from APP-SG (specific instances only)
Business Impact:
- High Availability: Multi-AZ deployment survived complete AZ outage during peak season
- Cost Savings: Proper CIDR planning avoided network re-architecture ($200K+ project cost)
- Compliance: Isolated PCI-DSS environment passed audit on first attempt
- Performance: Load balancers in public subnets reduced latency by 35ms average
Scenario 2: Multi-Tenant SaaS Platform (Scale: 1000+ enterprise customers)
Company Profile: DataFlow Analytics, B2B SaaS with enterprise security requirements Challenge: Tenant isolation, regulatory compliance (GDPR, HIPAA), cost optimization Requirements: Network-level tenant isolation, audit trails, disaster recovery
Multi-VPC Strategy:
Management VPC: 10.0.0.0/16 (Shared services)
Tenant VPC Pattern: 10.X.0.0/16 (Per customer/region)
└── Customer A EU: 10.10.0.0/16 (eu-west-1)
└── Customer B US: 10.20.0.0/16 (us-east-1)
└── Customer C HIPAA: 10.30.0.0/16 (us-west-2)
VPC Peering Configuration:
# Connect tenant VPCs to management VPC for shared services
aws ec2 create-vpc-peering-connection \
--vpc-id vpc-management \
--peer-vpc-id vpc-customer-a \
--peer-region eu-west-1
Common Implementation Patterns:
- Hub-and-Spoke Architecture:
- Central management VPC for shared services (logging, monitoring, CI/CD)
- Spoke VPCs for individual workloads or customers
- VPC peering or Transit Gateway for controlled connectivity
- Environment Segregation:
Dev VPC: 10.1.0.0/16 Staging VPC: 10.2.0.0/16 Production VPC: 10.0.0.0/16 - Microservices Network Patterns:
- Service mesh integration with VPC native networking
- Container networking with EKS/ECS across multiple subnets
- API Gateway integration for serverless connectivity
Multi-Account Strategies:
AWS recommends separate accounts for different environments, connected through:
- AWS Organizations: Centralized billing and governance
- Cross-account VPC peering: Controlled network connectivity
- PrivateLink: Service-to-service communication without peering
- Transit Gateway: Scalable connectivity for 100+ VPCs
Anti-Patterns to Avoid:
- Single Large Subnet:
❌ Don't: VPC with one /16 subnet ✅ Do: Multiple /24 subnets across AZs and tiers - Overlapping CIDR Blocks:
❌ Don't: VPC-A: 10.0.0.0/16, VPC-B: 10.0.0.0/24 ✅ Do: VPC-A: 10.0.0.0/16, VPC-B: 10.1.0.0/16 - Public Database Subnets:
❌ Don't: RDS in public subnet with 0.0.0.0/0 access ✅ Do: RDS in private subnet with application-only access
Industry Examples:
- Netflix: Uses hundreds of VPCs across multiple regions for content delivery and microservices isolation
- Airbnb: Implements hub-and-spoke VPC architecture for global operations with regional compliance
- Spotify: Uses VPC-per-team model with centralized networking services for developer autonomy
SAA-C03 Exam Focus
Exam Weight: VPC topics comprise approximately 15% of the SAA-C03 exam, appearing in:
- Design Secure Architectures (30% domain)
- Design Resilient Architectures (26% domain)
- Design High-Performing Architectures (24% domain)
Question Types and Patterns
Scenario-Based Questions: The exam frequently presents business scenarios requiring network design decisions:
“A company needs to deploy a 3-tier web application with high availability. The database should not be accessible from the internet, but the application servers need outbound internet access for software updates. Which VPC configuration provides this functionality with the least operational overhead?”
Key Exam Concepts Tested:
- Subnet Types and Internet Connectivity:
- Public subnet = route to Internet Gateway
- Private subnet = route to NAT Gateway/Instance for outbound-only access
- Database subnet = no internet routes, internal communication only
- Security Group vs NACL Decision Points:
Security Groups: Stateful, instance-level, allow rules only NACLs: Stateless, subnet-level, allow/deny rules, numbered priority - Routing Troubleshooting:
- Most specific route wins (longest prefix match)
- Route table association priority: subnet > main route table
- Local routes cannot be overridden
- High Availability Patterns:
- Subnets span single AZ, resources in multiple AZs for HA
- NAT Gateway per AZ vs single NAT Gateway cost/availability tradeoff
🎯 Exam Tip: When questions mention “least operational overhead,” the answer usually involves managed services (NAT Gateway vs NAT Instance, Application Load Balancer vs Network Load Balancer).
Common Exam Scenarios:
- Database Access Control:“Database servers should only accept connections from application servers on port 3306”
- Answer: Security group on database allowing source security group of app servers
- Internet Access Patterns:“Web servers need inbound and outbound internet access, app servers need only outbound”
- Answer: Web servers in public subnet, app servers in private subnet with NAT Gateway
- Cost Optimization:“Reduce costs for development environment with minimal internet usage”
- Answer: Single NAT Gateway instead of per-AZ deployment, or NAT Instance
Practice Questions:
Question 1: A solutions architect needs to design a VPC for a new application. The application requires web servers accessible from the internet and database servers that should never have internet access. The database servers need to download security patches. Which design meets these requirements?
A) Put web servers and database servers in public subnets with restrictive security groups B) Put web servers in public subnets and database servers in private subnets with a NAT Gateway C) Put all servers in private subnets and use a NAT Instance for internet access D) Put web servers in public subnets and database servers in private subnets without internet access
Answer: B – Web servers need direct internet access (public subnet), database servers need outbound-only access for patches (private subnet with NAT Gateway). Option A violates security requirements, C adds unnecessary complexity, D prevents security updates.
Question 3 (NEW): A company runs NAT Gateways in us-east-1a and us-east-1b for high availability. During a maintenance window, us-east-1a experiences a complete outage. What happens to private subnet instances in us-east-1b?
A) All private instances lose internet connectivity until us-east-1a recovers B) Private instances in us-east-1b continue operating normally with internet access C) Traffic automatically fails over to the NAT Gateway in us-east-1b after 5 minutes D) Private instances can access internet but with increased latency
Answer: B – NAT Gateways are AZ-specific resources. Private subnets in us-east-1b route to their local NAT Gateway, so an outage in us-east-1a doesn’t affect resources in us-east-1b. This demonstrates why multi-AZ NAT Gateway deployment eliminates single points of failure.
Question 4 (NEW): A security team needs to block all SSH traffic to database servers while allowing application servers to connect on port 3306. The application servers are in security group sg-app and database servers are in sg-db. Which configuration achieves this with least administrative overhead?
A) Security Group sg-db: Allow TCP 3306 from sg-app, Deny TCP 22 from 0.0.0.0/0 B) Security Group sg-db: Allow TCP 3306 from sg-app (no SSH rules needed) C) NACL on database subnet: Allow TCP 3306 from app subnet CIDR, Deny TCP 22 D) Both Security Group rules and NACL rules for defense in depth
Answer: B – Security Groups are “default deny” and only support ALLOW rules. Simply allowing port 3306 from sg-app automatically blocks all other traffic including SSH. Option A is invalid (SGs don’t have DENY rules), C adds complexity, D is over-engineering for this requirement.
✅ Exam Tip: Security Group questions often test understanding that they are stateful and “allow-only.” When you see answer choices with “DENY” rules in Security Groups, eliminate them immediately.
VPC Memory Palace for SAA-C03
| Concept | Must-Know | SAA-C03 Frequency | Memory Trick |
|---|---|---|---|
| Route Tables | Longest prefix match wins | 92% | “Most specific route = most specific person gets the mail” |
| Security Groups | Stateful, allow rules only | 100% | “Security Guard only says YES, never NO” |
| NACLs | Stateless, rule number priority | 87% | “Network Access Control List = Numbered Access Control” |
| NAT Gateway | AZ-resilient, $0.045/hr + data | 78% | “NAT = Network Address Translation for outbound only” |
| Subnet CIDR | Always subtract 5 from total IPs | 85% | “AWS Always takes Away 5 Addresses” |
| Internet Gateway | One per VPC, highly available | 73% | “Internet Gate = Single entrance to internet” |
Site-to-Site VPN and Hybrid Connectivity
Missing Exam-Relevant Content Enhancement:
VPN Components and Route Propagation
# Create Customer Gateway (your on-premises router)
aws ec2 create-customer-gateway \
--type ipsec.1 \
--public-ip 203.0.113.12 \
--bgp-asn 65000 \
--tag-specifications 'ResourceType=customer-gateway,Tags=[{Key=Name,Value=OnPrem-CGW}]'
# Create Virtual Private Gateway
aws ec2 create-vpn-gateway \
--type ipsec.1 \
--tag-specifications 'ResourceType=vpn-gateway,Tags=[{Key=Name,Value=Production-VGW}]'
# Attach VGW to VPC
aws ec2 attach-vpn-gateway \
--vpn-gateway-id vgw-xxxxxxxx \
--vpc-id vpc-xxxxxxxx
# Create Site-to-Site VPN Connection
aws ec2 create-vpn-connection \
--type ipsec.1 \
--customer-gateway-id cgw-xxxxxxxx \
--vpn-gateway-id vgw-xxxxxxxx \
--options StaticRoutesOnly=false
Route Propagation for Hybrid Connectivity:
# Enable route propagation on private route tables
aws ec2 enable-vgw-route-propagation \
--route-table-id rtb-private-xxxxxxxx \
--gateway-id vgw-xxxxxxxx
# Verify propagated routes
aws ec2 describe-route-tables \
--route-table-ids rtb-private-xxxxxxxx \
--query 'RouteTables[0].Routes[?Origin==`CreateRoute`]'
Centralized Networking (Shared Services VPC Pattern)
Hub-and-Spoke with Shared Services:
Shared Services VPC (10.0.0.0/16):
├── Active Directory servers
├── DNS forwarders
├── Centralized logging
├── CI/CD infrastructure
├── Security scanning tools
Connected Workload VPCs:
├── Production VPC (10.1.0.0/16) ← peered to Shared Services
├── Staging VPC (10.2.0.0/16) ← peered to Shared Services
├── Development VPC (10.3.0.0/16) ← peered to Shared Services
Shared Services Route Configuration:
# Route table in workload VPCs pointing to shared services
aws ec2 create-route \
--route-table-id rtb-workload-private \
--destination-cidr-block 10.0.0.0/16 \
--vpc-peering-connection-id pcx-xxxxxxxx
# Security group allowing shared services access
aws ec2 authorize-security-group-ingress \
--group-id sg-workload-instances \
--protocol tcp \
--port 53 \
--source-group sg-shared-dns-servers
Container Networking Integration
EKS CNI Plugin and IP Address Planning
Amazon EKS uses the AWS VPC CNI plugin, which assigns VPC IP addresses directly to pods.
EKS IP Address Consumption:
Node Instance Type: m5.large
- Total ENIs: 3
- IPs per ENI: 10
- Total IPs: 30
- Reserved for node: 1
- Available for pods: 29 pods per node
Subnet Planning for EKS:
- 100-node cluster = 2,900 pod IPs needed
- Use /20 subnet (4,091 usable IPs) minimum
- Consider /19 or larger for auto-scaling
EKS Subnet Configuration:
# Tag subnets for EKS discovery
aws ec2 create-tags \
--resources subnet-xxxxxxxx \
--tags Key=kubernetes.io/role/elb,Value=1
aws ec2 create-tags \
--resources subnet-yyyyyyyy \
--tags Key=kubernetes.io/role/internal-elb,Value=1
aws ec2 create-tags \
--resources subnet-xxxxxxxx subnet-yyyyyyyy \
--tags Key=kubernetes.io/cluster/my-cluster,Value=shared
IAM Policy for Least Privilege VPC Management
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "VPCReadAccess",
"Effect": "Allow",
"Action": [
"ec2:DescribeVpcs",
"ec2:DescribeSubnets",
"ec2:DescribeRouteTables",
"ec2:DescribeSecurityGroups",
"ec2:DescribeNetworkAcls",
"ec2:DescribeInternetGateways",
"ec2:DescribeNatGateways"
],
"Resource": "*"
},
{
"Sid": "VPCResourceCreation",
"Effect": "Allow",
"Action": [
"ec2:CreateSecurityGroup",
"ec2:AuthorizeSecurityGroupIngress",
"ec2:AuthorizeSecurityGroupEgress",
"ec2:RevokeSecurityGroupIngress",
"ec2:RevokeSecurityGroupEgress"
],
"Resource": "*",
"Condition": {
"StringEquals": {
"aws:RequestedRegion": ["us-east-1", "us-west-2"]
}
}
},
{
"Sid": "VPCTagging",
"Effect": "Allow",
"Action": [
"ec2:CreateTags",
"ec2:DeleteTags"
],
"Resource": "*",
"Condition": {
"StringEquals": {
"ec2:CreateAction": [
"CreateSecurityGroup",
"CreateVpc",
"CreateSubnet"
]
}
}
}
]
}
To understand how these IAM permissions work at a deeper level—including inline vs managed policies, permission boundaries, and designing least-privilege roles—check out my Complete AWS IAM Tutorial.
Production Subnet Planning Table
| Tier | AZ | CIDR | Usable IPs | Route Target | Primary Use Case |
|---|---|---|---|---|---|
| Public | us-east-1a | 10.0.1.0/24 | 251 | igw-123 | ALB, NAT Gateway, Bastion |
| Public | us-east-1b | 10.0.2.0/24 | 251 | igw-123 | ALB, NAT Gateway, Bastion |
| Private App | us-east-1a | 10.0.11.0/24 | 251 | nat-gw-1a | Web/App servers |
| Private App | us-east-1b | 10.0.12.0/24 | 251 | nat-gw-1b | Web/App servers |
| Private DB | us-east-1a | 10.0.21.0/24 | 251 | Local only | RDS, ElastiCache |
| Private DB | us-east-1b | 10.0.22.0/24 | 251 | Local only | RDS, ElastiCache |
| EKS Nodes | us-east-1a | 10.0.31.0/20 | 4,091 | nat-gw-1a | Kubernetes worker nodes |
| EKS Nodes | us-east-1b | 10.0.47.0/20 | 4,091 | nat-gw-1b | Kubernetes worker nodes |
Cost Comparison Matrix
| Component | Free Tier | Production Cost (Monthly) | Development Savings Hack | ROI Impact |
|---|---|---|---|---|
| NAT Gateway | ❌ | $32.40 + data | Use t3.nano NAT Instance ($4) | 85% savings |
| VPC Endpoint (Interface) | Partial | $7.30 + $0.01/GB | Gateway endpoints for S3/DDB (free) | Variable |
| VPN Connection | ❌ | $36.50 | Use temporary connections | Time-based |
| Transit Gateway | ❌ | $36.50/attachment + data | Direct VPC peering for <4 VPCs | 4+ VPC break-even |
| Cross-AZ Data Transfer | ❌ | $0.01/GB each direction | Single-AZ for non-HA workloads | Architecture dependent |
Advanced VPC Flow Logs Integration
Custom Flow Logs Format for Security Monitoring:
# Create enhanced Flow Logs for security analysis
aws ec2 create-flow-logs \
--resource-type NetworkInterface \
--resource-ids eni-xxxxxxxx \
--traffic-type ALL \
--log-destination-type cloud-watch-logs \
--log-group-name /security/vpc-flow-logs \
--log-format '${version} ${account-id} ${interface-id} ${srcaddr} ${dstaddr} ${srcport} ${dstport} ${protocol} ${packets} ${bytes} ${windowstart} ${windowend} ${action} ${tcp-flags} ${type} ${pkt-srcaddr} ${pkt-dstaddr}'
CloudWatch Logs Insights for Threat Detection:
# Detect potential port scanning
fields @timestamp, srcaddr, dstaddr, dstport, action
| filter action = "REJECT"
| stats count() by srcaddr, dstaddr
| where count > 100
| sort count desc
# Monitor unusual outbound connections
fields @timestamp, srcaddr, dstaddr, dstport, protocol, action
| filter action = "ACCEPT" and srcaddr like /^10\.0\./
| stats count() by dstaddr, dstport
| where count > 1000
| sort count desc
# Analyze blocked database access attempts
fields @timestamp, srcaddr, dstaddr, dstport, action, protocol
| filter dstport in [3306, 5432, 1433] and action = "REJECT"
| stats count() by srcaddr, bin(5m)
| sort @timestamp desc
Advanced Cost Optimization Strategies
Multi-Account NAT Gateway Sharing:
# Share NAT Gateway across accounts using RAM
aws ram create-resource-share \
--name "shared-nat-gateway" \
--resource-arns arn:aws:ec2:us-east-1:123456789012:natgateway/nat-xxxxxxxx \
--principals 987654321098,567890123456 \
--allow-external-principals
VPC Endpoint Cost Analysis Decision Tree:
if (monthly_s3_api_calls > 2.5TB_equivalent) {
use_vpc_endpoint_gateway(); // Free for S3/DynamoDB
} else if (security_requirements == "high") {
use_vpc_endpoint_interface(); // $7.30/month + data
} else {
use_nat_gateway(); // $32.40/month + data
}
Spot Instance NAT Solution:
#!/bin/bash
# Launch NAT instance on Spot for 70% cost savings
aws ec2 request-spot-instances \
--spot-price "0.008" \
--instance-count 1 \
--type "one-time" \
--launch-specification '{
"ImageId": "ami-00a9d4a05375b2763",
"InstanceType": "t3.nano",
"KeyName": "nat-key",
"SecurityGroups": [{"GroupId": "sg-nat-xxxxxxxx"}],
"SubnetId": "subnet-public-xxxxxxxx",
"UserData": "IyEvYmluL2Jhc2gKZWNobyBuZXQua..."
}'
Reserved Capacity Planning for Predictable Workloads
VPN Connection Reserved Pricing Analysis:
Standard VPN: $0.05/hour = $438/year
Potential Reserved: $262.50/year (40% savings)
Break-even: 6+ months of continuous usage
Data Transfer Commitment Discounts:
Monthly Transfer Volume | Standard Rate | Committed Rate | Annual Savings
1-10TB | $0.09/GB | $0.085/GB | $600-6,000
10-50TB | $0.085/GB | $0.070/GB | $9,000-45,000
50TB+ | Custom pricing negotiation
Elimination Strategies:
- Internet Access Questions: Eliminate answers that put databases in public subnets or deny required outbound access
- Cost Questions: Look for managed services (NAT Gateway) vs self-managed (NAT Instance) tradeoffs
- Security Questions: Choose most restrictive option that still meets functional requirements
- CIDR Planning: Calculate usable addresses and expansion capacity for each option
Troubleshooting & Monitoring
Common Error 1: EC2 Instance Can’t Reach Internet
Symptoms:
$ ping google.com
ping: google.com: Name or service not known
$ curl -I https://aws.amazon.com
curl: (6) Could not resolve host: aws.amazon.com
Root Cause Analysis:
- Check instance subnet type (public vs private)
- Verify route table associations
- Confirm security group outbound rules
- Validate NACL settings
Step-by-Step Solution:
- Verify Subnet Configuration:
# Check if instance is in public subnet
aws ec2 describe-subnets --subnet-ids subnet-xxxxxxxx
# Look for MapPublicIpOnLaunch: true and route to Internet Gateway
- Check Route Table:
# Find route table associated with subnet
aws ec2 describe-route-tables --filters "Name=association.subnet-id,Values=subnet-xxxxxxxx"
# Verify 0.0.0.0/0 route exists pointing to:
# - igw-xxxxxxxx (for public subnet)
# - nat-xxxxxxxx (for private subnet)
- Validate Security Groups:
# Check outbound rules (should include 0.0.0.0/0 on required ports)
aws ec2 describe-security-groups --group-ids sg-xxxxxxxx
# Default outbound rule should be:
# 0.0.0.0/0, All traffic, All ports
- Console Debugging:
- VPC → Route Tables → Select route table → Routes tab
- EC2 → Security Groups → Outbound rules
- VPC → Network ACLs → Outbound rules
Common Error 2: Cross-Subnet Communication Failure
Symptoms:
# From web server in public subnet
$ telnet 10.0.11.5 3306
Trying 10.0.11.5...
telnet: connect to address 10.0.11.5: Connection timed out
Root Cause: Security group or NACL blocking traffic between subnets
Step-by-Step Solution:
- Check Security Group Rules:
# Database security group should allow source security group of web servers
aws ec2 describe-security-groups --group-ids sg-database
# Look for inbound rule:
# Source: sg-webserver, Protocol: TCP, Port: 3306
- Verify NACL Configuration:
# Check subnet NACL rules
aws ec2 describe-network-acls --filters "Name=association.subnet-id,Values=subnet-xxxxxxxx"
# Ensure both inbound and outbound rules allow traffic
# Remember: NACLs are STATELESS
- Test Network Connectivity:
# From source instance, test specific port
nc -zv 10.0.11.5 3306
# Check if ping works (ICMP)
ping 10.0.11.5
# Trace network path
traceroute 10.0.11.5
Enhanced Troubleshooting with VPC Reachability Analyzer
AWS provides advanced network troubleshooting tools beyond basic connectivity tests.
VPC Reachability Analyzer
# Create network insights path to analyze connectivity
aws ec2 create-network-insights-path \
--source i-1234567890abcdef0 \
--destination i-0987654321fedcba0 \
--protocol tcp \
--destination-port 3306
# Start analysis
aws ec2 start-network-insights-analysis \
--network-insights-path-id nip-xxxxxxxxx
# Get detailed analysis results
aws ec2 describe-network-insights-analyses \
--network-insights-analysis-ids nia-xxxxxxxxx
Reachability Analyzer Use Cases:
- Troubleshoot RDS connectivity from EC2 instances
- Verify load balancer target health check paths
- Analyze cross-VPC peering connectivity issues
- Validate security group and NACL rule effectiveness
VPC Flow Logs Analysis for Blocked Traffic
# Enable VPC Flow Logs with custom format
aws ec2 create-flow-logs \
--resource-type VPC \
--resource-ids vpc-xxxxxxxx \
--traffic-type ALL \
--log-destination-type cloud-watch-logs \
--log-group-name /aws/vpc/flowlogs \
--log-format '${srcaddr} ${dstaddr} ${srcport} ${dstport} ${protocol} ${action} ${start} ${end}'
CloudWatch Logs Insights Queries for Flow Logs:
# Find blocked traffic by source IP
fields @timestamp, srcaddr, dstaddr, srcport, dstport, protocol, action
| filter action = "REJECT"
| stats count() by srcaddr
| sort count desc
# Analyze blocked database connections
fields @timestamp, srcaddr, dstaddr, srcport, dstport, action
| filter dstport = 3306 and action = "REJECT"
| sort @timestamp desc
# Traffic volume by destination port
fields @timestamp, dstport, action
| filter action = "ACCEPT"
| stats count() by dstport
| sort count desc
Flow Logs Custom Format for Security Analysis:
${version} ${account-id} ${interface-id} ${srcaddr} ${dstaddr} ${srcport} ${dstport} ${protocol} ${packets} ${bytes} ${windowstart} ${windowend} ${action} ${flowlogstatus}
Symptoms:
- Private subnet instances can’t reach internet
- Software updates fail
- API calls to external services timeout
Step-by-Step Solution:
- Verify NAT Gateway Status:
# Check NAT Gateway state
aws ec2 describe-nat-gateways --nat-gateway-ids nat-xxxxxxxx
# State should be "available"
# SubnetId should be a PUBLIC subnet
- Check Route Configuration:
# Private subnet route table should have:
# Destination: 0.0.0.0/0, Target: nat-xxxxxxxx
aws ec2 describe-route-tables --filters "Name=association.subnet-id,Values=subnet-private"
- Validate Elastic IP:
# NAT Gateway needs EIP in public subnet
aws ec2 describe-addresses --filters "Name=network-interface-id,Values=eni-*"
CloudWatch Integration and Monitoring
Essential VPC Metrics to Monitor:
- NAT Gateway Metrics:
# CloudWatch metrics to track
aws cloudwatch get-metric-statistics \
--namespace AWS/NatGateway \
--metric-name BytesOutToDestination \
--dimensions Name=NatGatewayId,Value=nat-xxxxxxxx \
--start-time 2025-01-01T00:00:00Z \
--end-time 2025-01-02T00:00:00Z \
--period 3600 \
--statistics Sum
- VPC Flow Logs Setup:
# Enable VPC Flow Logs for security monitoring
aws ec2 create-flow-logs \
--resource-type VPC \
--resource-ids vpc-xxxxxxxx \
--traffic-type ALL \
--log-destination-type cloud-watch-logs \
--log-group-name /aws/vpc/flowlogs \
--deliver-logs-permission-arn arn:aws:iam::123456789012:role/flowlogsRole
- Custom CloudWatch Dashboard:
{
"widgets": [
{
"type": "metric",
"properties": {
"metrics": [
["AWS/NatGateway", "BytesOutToDestination", "NatGatewayId", "nat-xxxxxxxx"],
[".", "PacketsOutToDestination", ".", "."],
[".", "ActiveConnectionCount", ".", "."]
],
"period": 300,
"stat": "Average",
"region": "us-east-1",
"title": "NAT Gateway Performance"
}
}
]
}
AWS Support Cases – When to Escalate:
- Network connectivity issues persisting after route table and security group validation
- Unusual NAT Gateway charges or performance degradation
- VPC limits requiring increases beyond standard soft limits
- Cross-region peering connection failures
Information to Include in Support Cases:
- VPC ID, subnet IDs, and instance IDs involved
- Complete network topology diagram
- Relevant CloudWatch metrics and Flow Log entries
- Step-by-step troubleshooting attempts already performed
Health Checks and Monitoring Commands:
# Comprehensive VPC health check script
#!/bin/bash
VPC_ID="vpc-xxxxxxxx"
echo "=== VPC Health Check Report ==="
echo "VPC ID: $VPC_ID"
echo "Timestamp: $(date)"
# Check VPC basic info
aws ec2 describe-vpcs --vpc-ids $VPC_ID --query 'Vpcs[0].[VpcId,CidrBlock,State]' --output table
# List all subnets
echo -e "\n=== Subnets ==="
aws ec2 describe-subnets --filters "Name=vpc-id,Values=$VPC_ID" \
--query 'Subnets[*].[SubnetId,CidrBlock,AvailabilityZone,MapPublicIpOnLaunch]' --output table
# Check Internet Gateway
echo -e "\n=== Internet Gateway ==="
aws ec2 describe-internet-gateways --filters "Name=attachment.vpc-id,Values=$VPC_ID" \
--query 'InternetGateways[*].[InternetGatewayId,State]' --output table
# Check NAT Gateways
echo -e "\n=== NAT Gateways ==="
aws ec2 describe-nat-gateways --filters "Name=vpc-id,Values=$VPC_ID" \
--query 'NatGateways[*].[NatGatewayId,State,SubnetId]' --output table
# Check Route Tables
echo -e "\n=== Route Tables ==="
aws ec2 describe-route-tables --filters "Name=vpc-id,Values=$VPC_ID" \
--query 'RouteTables[*].[RouteTableId,Routes[0].DestinationCidrBlock,Routes[0].GatewayId]' --output table
Performance Optimization:
- Network Latency Optimization:
- Place resources in same AZ when low latency is critical
- Use Placement Groups for HPC workloads
- Consider Enhanced Networking for high-bandwidth applications
- NAT Gateway Optimization:
- Deploy NAT Gateway in each AZ for high availability
- Monitor bandwidth utilization and scale horizontally if needed
- Use NAT Instance with custom AMI for specialized routing needs
- Security Group Optimization:
- Minimize number of rules per security group
- Use security group references instead of CIDR blocks when possible
- Regularly audit and remove unused security groups
Cost Optimization Strategies
Free Tier Usage Maximization
Free Tier Usage and Hidden Costs
Always Free VPC Components:
- VPC creation and management
- Subnets (unlimited)
- Route Tables and Internet Gateways
- Security Groups and NACLs
- VPC Endpoints (Gateway type for S3/DynamoDB)
Components with Charges:
- NAT Gateway: $0.045/hour + $0.045/GB processed = ~$32.40/month + data charges
- VPC Endpoints (Interface): $0.01/hour + $0.01/GB processed
- VPN Connections: $0.05/hour per connection = $36.50/month
- VPC Peering: $0.01/GB for cross-region data transfer
- Transit Gateway: $0.05/hour per attachment + $0.02/GB data processing
❗ Hidden Cost Warning: Cross-AZ data transfer within the same region costs $0.01/GB in each direction, even for free tier accounts. This affects NAT Gateway placement and multi-AZ designs.
Cost Comparison: NAT Gateway vs NAT Instance
NAT Gateway (Managed Service):
Monthly Cost = Hours * $0.045 + GB processed * $0.045
Example: 730 hours * $0.045 + 100GB * $0.045 = $32.85 + $4.50 = $37.35/month
NAT Instance (Self-Managed):
t3.nano: 730 hours * $0.0052 = $3.80/month
t3.micro: 730 hours * $0.0104 = $7.59/month
+ EBS storage: 8GB * $0.10 = $0.80/month
💰 Real Savings Example: A development team reduced NAT costs by 85% ($37/month → $5/month) by switching to NAT instances for non-production environments, saving $384 annually per environment.
Reserved Capacity and Cost Planning
VPN Connection Optimization:
Standard pricing: $0.05/hour = $36.50/month
Annual commitment could reduce costs for permanent connections
Alternative: AWS Direct Connect for higher bandwidth needs
“Want to go deeper on connecting your on-premise data center? Read our Advanced Guide to Direct Connect & BGP here.”
Multi-AZ NAT Strategy Cost Impact:
Single NAT Gateway: $32.40/month (single point of failure)
Multi-AZ NAT Gateway: $64.80/month (high availability)
Cost vs availability tradeoff based on business requirements
Resource Right-Sizing Strategies
- Subnet CIDR Optimization:
- Start with /24 subnets (256 addresses) for most use cases
- Use /20 subnets (4,096 addresses) only for auto-scaling workloads
- Avoid /16 subnets unless managing thousands of resources
- NAT Gateway Bandwidth Planning:
- Monitor BytesOutToDestination metric
- Single NAT Gateway supports up to 45 Gbps
- Scale horizontally rather than vertically for cost efficiency
- VPC Endpoint Cost Analysis:
# Calculate VPC Endpoint vs NAT Gateway costs # VPC Endpoint: $0.01/hour + $0.01/GB = $7.30 + data charges # NAT Gateway: $32.40 + data charges # Break-even point: ~2.5TB/month of S3/DynamoDB traffic
Cost Monitoring Setup
CloudWatch Billing Alerts:
# Create billing alarm for NAT Gateway costs
aws cloudwatch put-metric-alarm \
--alarm-name "NAT-Gateway-Monthly-Cost" \
--alarm-description "Alert when NAT Gateway costs exceed $50" \
--metric-name EstimatedCharges \
--namespace AWS/Billing \
--statistic Maximum \
--period 86400 \
--threshold 50 \
--comparison-operator GreaterThanThreshold \
--dimensions Name=Currency,Value=USD Name=ServiceName,Value=AmazonVPC \
--evaluation-periods 1
Cost Allocation Tags:
{
"Tags": [
{"Key": "Environment", "Value": "production"},
{"Key": "Project", "Value": "web-app"},
{"Key": "CostCenter", "Value": "engineering"},
{"Key": "Owner", "Value": "devops-team"}
]
}
💰 Cost Calculator Examples:
Scenario 1: Startup Web Application
VPC + Subnets + IGW: $0.00
Single NAT Gateway: $32.40/month
Application Load Balancer: $16.20/month
Total monthly networking cost: $48.60
Scenario 2: Enterprise Multi-Tier Application
VPC + Subnets + IGW: $0.00
3x NAT Gateways (Multi-AZ): $97.20/month
2x Application Load Balancers: $32.40/month
VPC Flow Logs (CloudWatch): ~$10/month
Total monthly networking cost: $139.60
Use the AWS Pricing Calculator to model your specific architecture costs.
Next Steps & Learning Path
Ready to take your VPC expertise to the next level? In our next post, we’ll dive deep into VPC Security Groups vs Network ACLs – the critical security layers that protect your applications from threats.
Compelling preview: Ever wondered why a security group rule allows traffic but your application still can’t connect? We’ll decode the mysterious world of stateful vs stateless firewalls, debug common security scenarios, and reveal the insider techniques AWS professionals use to design bulletproof network security. You’ll learn why Netflix uses hundreds of security groups and how Airbnb’s NACL strategy prevented a major security incident.
Certification Progress: 🎯 You’re now 15% ready for the Design Secure Architectures domain of SAA-C03! VPC fundamentals are the foundation for 75% of networking questions on the exam.
Hands-on Challenges:
- Beginner Challenge: Create a 3-tier VPC with public, private, and database subnets. Deploy a web server in the public subnet and verify internet connectivity.
- Intermediate Challenge: Implement a multi-region VPC architecture with VPC peering between us-east-1 and eu-west-1. Test cross-region connectivity and measure latency.
- Advanced Challenge: Design a hub-and-spoke VPC architecture for a SaaS company with 5 customer environments, shared services, and compliance isolation requirements.
Additional Resources:
- 📖 AWS VPC User Guide – Official comprehensive documentation
- 📄 VPC Security Best Practices Whitepaper
- 🎥 AWS re:Invent VPC Deep Dive Sessions – Latest architecture patterns
Community Engagement: Share your VPC architecture diagrams in the comments! What’s your biggest networking challenge? Are you planning single-region or multi-region deployment? Let’s discuss the tradeoffs and learn from each other’s experiences.
Career Relevance: VPC design skills directly apply to:
- Cloud Solutions Architect roles ($120K-$180K average salary)
- DevOps Engineer positions requiring AWS networking expertise
- Security Engineer roles focused on cloud infrastructure protection
- Site Reliability Engineer positions managing large-scale distributed systems
FAQ Section
What’s the difference between a public subnet and a private subnet in AWS VPC?
A public subnet has a route table entry directing traffic (0.0.0.0/0) to an Internet Gateway, allowing resources to receive inbound internet traffic and communicate directly outbound. A private subnet routes traffic to a NAT Gateway or NAT Instance, providing outbound-only internet access while preventing inbound connections from the internet. Resources in private subnets are not directly accessible from the internet.
How many IP addresses are actually usable in a /24 subnet?
/24 subnet provides 256 total IP addresses, but only 251 are usable for EC2 instances. AWS reserves 5 IP addresses in every subnet: network address (.0), VPC router (.1), DNS server (.2), future use (.3), and broadcast address (.255). For example, in subnet 10.0.1.0/24, usable addresses are 10.0.1.4 through 10.0.1.254.
Can I change the CIDR block of an existing VPC?
You cannot modify the primary CIDR block of an existing VPC, but you can add additional CIDR blocks (up to 4 secondary blocks per VPC). To change the primary CIDR, you must create a new VPC and migrate resources. This is why proper CIDR planning is critical during initial VPC design – always choose a block size that accommodates future growth.
What happens if two VPCs have overlapping CIDR blocks and I try to peer them?
VPC peering connections cannot be established between VPCs with overlapping CIDR blocks. AWS will reject the peering request because routing would be ambiguous – the network wouldn’t know which VPC should receive traffic for overlapping IP ranges. This is why using unique CIDR blocks (like 10.0.0.0/16, 10.1.0.0/16, 10.2.0.0/16) is essential for multi-VPC architectures.
How does VPC relate to SAA-C03 exam questions about high availability?
VPC high availability questions typically focus on multi-AZ deployments, subnet design across Availability Zones, and NAT Gateway placement strategies. Common scenarios test whether you understand that subnets are AZ-specific, so you need subnets in multiple AZs for high availability. Questions often compare single NAT Gateway (cost-effective but single point of failure) vs. per-AZ NAT Gateways (higher cost but eliminates failure points).
What’s the most cost-effective way to provide internet access for private subnets?
For production workloads, NAT Gateway ($32.40/month) provides managed service benefits with high availability. For development/testing environments with low traffic, a NAT Instance on t3.nano ($3.80/month) can reduce costs by 85%. For applications that only access S3 or DynamoDB, VPC Endpoints ($7.30/month) eliminate NAT Gateway data processing charges and provide better security by keeping traffic within AWS networks.
🔗 Connect with the Community:
- LinkedIn: Add “AWS VPC Design” to your skills and share this post
- GitHub: Star our AWS Architecture Examples repository
- Discord: Join our AWS study group for live discussions and exam tips
- Newsletter: Subscribe for weekly AWS tips and exam updates
💪 You’re Building Real AWS Expertise – Keep Going!
Ready to master the next layer of AWS networking security? Click the notification bell and let’s continue this journey together!

2 Comments