By Fatskills Exam Guides Team — the exam nerds behind 28,500+ quizzes and 2.1M practice questions across 500+ global exams.
For AWS Solutions Architect – Associate (SAA-C03) and Real-World Deployments
You’re a cloud engineer at a fintech startup. Your company has: - A legacy VPC (10.0.0.0/16) running a monolithic app in us-east-1.- A new microservices VPC (172.16.0.0/16) in the same region, hosting APIs and databases.- A third VPC (192.168.0.0/16) in us-west-2 for disaster recovery.
us-east-1
us-west-2
The problem:- Your microservices need to query the legacy app’s PostgreSQL database (private subnet).- The DR site must sync data nightly with the primary region.- Your developers complain about slow S3 uploads because traffic routes through a NAT gateway.
What breaks if you ignore this:- VPC Peering: If you don’t set it up, your VPCs can’t talk to each other. You’ll resort to public IPs or VPNs, which are slower, less secure, and cost more.- Transit Gateway: Without it, you’ll drown in a spaghetti of VPC peerings (N(N-1)/2 connections for N VPCs). Adding a 4th VPC? That’s 6 peerings to manage.- VPC Endpoints:* If you skip them, your private subnets will route S3/DynamoDB traffic through NAT gateways, adding latency and cost ($0.045/GB for NAT vs. $0.01/GB for Gateway Endpoints).
The superpower you gain:- VPC Peering: Simple, direct VPC-to-VPC communication (like a private LAN cable between two offices).- Transit Gateway: A single "hub" to connect all VPCs, VPNs, and on-prem networks (like a corporate switchboard).- VPC Endpoints: Private, high-speed access to AWS services (S3, DynamoDB, etc.) without leaving the AWS network (like a secret tunnel to the data center).
eu-west-1
Prerequisites:- AWS account with admin IAM permissions.- Two VPCs in the same region: - VPC-A: 10.0.0.0/16 (with a private subnet 10.0.1.0/24). - VPC-B: 172.16.0.0/16 (with a private subnet 172.16.1.0/24).- An EC2 instance in each VPC (Amazon Linux 2, t3.micro).
VPC-A
10.0.0.0/16
10.0.1.0/24
VPC-B
172.16.0.0/16
172.16.1.0/24
t3.micro
bash aws ec2 create-vpc-peering-connection \ --vpc-id vpc-1234567890abcdef0 \ # VPC-A --peer-vpc-id vpc-0987654321fedcba0 \ # VPC-B --peer-region us-east-1
Output: Note the VpcPeeringConnectionId (e.g., pcx-12345678).
VpcPeeringConnectionId
pcx-12345678
Accept the peering request (if cross-account): bash aws ec2 accept-vpc-peering-connection \ --vpc-peering-connection-id pcx-12345678
bash aws ec2 accept-vpc-peering-connection \ --vpc-peering-connection-id pcx-12345678
Add routes to both VPCs’ route tables:
bash aws ec2 create-route \ --route-table-id rtb-1234567890abcdef0 \ --destination-cidr-block 172.16.0.0/16 \ --vpc-peering-connection-id pcx-12345678
For VPC-B’s route table (attached to 172.16.1.0/24): bash aws ec2 create-route \ --route-table-id rtb-0987654321fedcba0 \ --destination-cidr-block 10.0.0.0/16 \ --vpc-peering-connection-id pcx-12345678
bash aws ec2 create-route \ --route-table-id rtb-0987654321fedcba0 \ --destination-cidr-block 10.0.0.0/16 \ --vpc-peering-connection-id pcx-12345678
Verify connectivity:
bash ping 172.16.1.100
bash aws ec2 create-vpc-endpoint \ --vpc-id vpc-1234567890abcdef0 \ # VPC-A --service-name com.amazonaws.us-east-1.s3 \ --vpc-endpoint-type Gateway \ --route-table-ids rtb-1234567890abcdef0
Output: Note the VpcEndpointId (e.g., vpce-12345678).
VpcEndpointId
vpce-12345678
Verify S3 access from the private subnet:
bash aws s3 ls
NatGatewayBytesOut
Create the endpoint: bash aws ec2 create-vpc-endpoint \ --vpc-id vpc-1234567890abcdef0 \ # VPC-A --service-name com.amazonaws.us-east-1.sqs \ --vpc-endpoint-type Interface \ --subnet-ids subnet-1234567890abcdef0 \ # Private subnet in VPC-A --security-group-ids sg-1234567890abcdef0 # Allow HTTPS (443)
bash aws ec2 create-vpc-endpoint \ --vpc-id vpc-1234567890abcdef0 \ # VPC-A --service-name com.amazonaws.us-east-1.sqs \ --vpc-endpoint-type Interface \ --subnet-ids subnet-1234567890abcdef0 \ # Private subnet in VPC-A --security-group-ids sg-1234567890abcdef0 # Allow HTTPS (443)
Test SQS access:
bash aws sqs list-queues
aws:PrincipalArn
json { "Version": "2012-10-17", "Statement": [ { "Effect": "Allow", "Principal": "*", "Action": "s3:*", "Resource": ["arn:aws:s3:::my-bucket/*"], "Condition": {"StringEquals": {"aws:SourceVpc": "vpc-12345678"}} } ] }
BytesIn
BytesOut
pcx-prod-to-dev-us-east-1
tgw-prod-hub-us-east-1
vpce-s3-gw-prod-us-east-1
Environment=prod
Owner=team-finance
VpcPeeringConnectionBytesIn/Out
TransitGatewayBytesIn/Out
VpcEndpointBytesIn/Out
VpcPeeringConnectionState
failed
❌ VPC Peering (5 VPCs = 10 peerings).
"A private subnet needs to access S3 without NAT. What’s the cheapest solution?"
❌ Interface Endpoint ($0.01/hour).
"A VPC in us-east-1 needs to access SQS in us-west-2. How?"
Challenge:You have: - A VPC (10.0.0.0/16) with a private subnet (10.0.1.0/24).- An EC2 instance in the private subnet.- A DynamoDB table (my-table) in the same region.
my-table
Task:Configure the private subnet to access DynamoDB without a NAT gateway or public internet.
Solution:
aws ec2 create-vpc-endpoint \ --vpc-id vpc-1234567890abcdef0 \ --service-name com.amazonaws.us-east-1.dynamodb \ --vpc-endpoint-type Gateway \ --route-table-ids rtb-1234567890abcdef0
Why it works:- Gateway Endpoints bypass the public internet and route DynamoDB traffic privately.- No NAT gateway costs (saves $0.045/GB).
bash aws ec2 create-vpc-peering-connection --vpc-id vpc-123 --peer-vpc-id vpc-456
bash aws ec2 create-transit-gateway --description "prod-hub"
aws ec2 create-vpc-endpoint --service-name com.amazonaws.us-east-1.s3 --vpc-endpoint-type Gateway
aws ec2 create-vpc-endpoint --service-name com.amazonaws.us-east-1.sqs --vpc-endpoint-type Interface
Final Tip:Bookmark this guide and try every step in a sandbox account. The best way to learn AWS networking is to break it, fix it, and break it again. ?
Join 4M+ learners. Unlock unlimited quizzes, wrong-answer tracking, flashcards + reminders, study guides, and 1-on-1 challenges.