When you start learning AWS, services like EC2, S3, Lambda, and RDS feel exciting.
But behind almost every real AWS architecture, there is one silent foundation:
Amazon VPC — Virtual Private Cloud
If EC2 is your server, RDS is your database, and ALB is your traffic manager, then VPC is the private network where all these resources live.
In this blog, we will understand:
- What is VPC
- CIDR and subnetting basics
- Public and private subnets
- Route tables
- Internet Gateway
- Security Groups
- VPC Peering
- Step-by-step VPC Peering example
🔗 Resources
** Support the Journey on GitHub:
If you're following along, consider starring and forking the repo:**
CIDR Calculater:
Internet Gateway
An Internet Gateway allows communication between your VPC and the internet.
For a subnet to become public, two things are required:
CODE1. Internet Gateway attached to VPC
2. Route table route:
0.0.0.0/0 → Internet Gateway
Security Groups
A Security Group acts like a virtual firewall for AWS resources.
AWS explains that a security group controls traffic allowed to reach an instance, and only traffic allowed by security group rules can reach that resource.
Security Groups are attached to resources like:
- EC2
- RDS
- Load Balancer
- Lambda inside VPC
Example Security Group rule:
CODEInbound Rules:
Type Port Source
SSH 22 Your IP
HTTP 80 0.0.0.0/0
HTTPS 443 0.0.0.0/0
Important point:
Security Groups are stateful.
That means if inbound traffic is allowed, response traffic is automatically allowed.
VPC Peering
VPC Peering allows two VPCs to communicate privately using private IP addresses.
Example:
CODEVPC-A: 10.0.0.0/16
VPC-B: 192.168.0.0/16
After VPC Peering:
CODEEC2 in VPC-A can communicate with EC2 in VPC-B privately.
Use cases:
- Connect two application VPCs
- Connect shared services VPC with app VPC
- Connect dev VPC with monitoring VPC
- Connect VPCs across accounts
- Connect VPCs across regions
Important: VPC Peering does not support overlapping CIDR blocks. AWS states that you cannot create a VPC peering connection if the VPCs have matching or overlapping IPv4 or IPv6 CIDR blocks.
Step-by-Step Example: Create VPC Peering
Let’s say we have two VPCs:
CODEVPC-A: 10.0.0.0/16
VPC-B: 192.168.0.0/16
Goal:
CODEEC2 instance in VPC-A should communicate with EC2 instance in VPC-B.
Step 1: Create VPC-A
Go to:
CODEAWS Console → VPC → Create VPC
Create:
CODEName: VPC-A
CIDR: 10.0.0.0/16
Create subnet:
CODEName: VPC-A-Private-Subnet
CIDR: 10.0.1.0/24
Step 2: Create VPC-B
Create second VPC:
CODEName: VPC-B
CIDR: 192.168.0.0/16
Create subnet:
CODEName: VPC-B-Private-Subnet
CIDR: 192.168.1.0/24
Step 3: Launch EC2 Instances
Launch one EC2 instance in each VPC.
CODEEC2-A → VPC-A → 10.0.1.0/24 subnet
EC2-B → VPC-B → 192.168.1.0/24 subnet
Make sure both instances have private IPs.
Example:
CODEEC2-A Private IP: 10.0.1.10
EC2-B Private IP: 192.168.1.10
Step 4: Create VPC Peering Connection
Go to:
CODEVPC Console → Peering Connections → Create Peering Connection
Fill details:
CODEName: VPC-A-to-VPC-B
Requester VPC: VPC-A
Accepter VPC: VPC-B
Click:
CODECreate Peering Connection
Step 5: Accept Peering Request
Go to:
CODEVPC → Peering Connections
Select the request.
Click:
CODEActions → Accept Request
Now the peering connection status should become:
CODEActive
Step 6: Update Route Table of VPC-A
Go to VPC-A route table.
Add route:
CODEDestination: 192.168.0.0/16
Target: VPC Peering Connection
AWS requires route tables on both sides to be updated so private IPv4 traffic can flow between peered VPCs. The destination should be the peer VPC CIDR and the target should be the VPC peering connection. ([AWS Documentation][6])
Step 7: Update Route Table of VPC-B
Go to VPC-B route table.
Add route:
CODEDestination: 10.0.0.0/16
Target: VPC Peering Connection
Now both VPCs know how to reach each other.
Step 8: Update Security Groups
For EC2-A security group, allow traffic from VPC-B:
CODEType: ICMP / SSH / Custom TCP
Source: 192.168.0.0/16
For EC2-B security group, allow traffic from VPC-A:
CODEType: ICMP / SSH / Custom TCP
Source: 10.0.0.0/16
For testing ping:
CODEAllow ICMP
For testing SSH:
CODEAllow TCP 22
Step 9: Test Connectivity
Login to EC2-A and ping EC2-B private IP:
CODEping 192.168.1.10
Or test SSH:
If route tables and security groups are correct, communication should work privately.
Final Thoughts
AWS VPC is one of the most important concepts in cloud networking.
If you understand VPC properly, then services like EC2, Load Balancer, RDS, EKS, Lambda networking, VPN, Direct Connect, and Transit Gateway become much easier.
At a high level, remember this:
CODEVPC = Your private network in AWS
Subnet = Smaller network inside VPC
Route Table = Traffic direction rules
Internet Gateway = Internet access
Security Group = Firewall for resources
VPC Peering = Private connection between two VPCs
↗ Original-Artikel auf dev.to lesenVollständiger Original-BerichtAusführliche Details, Code-Beispiele & Hersteller-Stellungnahme auf dev.to.

SOCIAL SHARE CARD GENERATOR