AWS Builder Center
AWS VPC Peering: Secure and Private Communication Between Virtual Private Clouds

AWS VPC Peering: Secure and Private Communication Between Virtual Private Clouds

AWS VPC Peering enables secure, private communication between two Amazon Virtual Private Clouds (VPCs) using private IP addresses without routing traffic over the public internet. In this article, explore its architecture, working principles, step-by-step configuration, route table setup, security groups, real-world use cases, limitations, and best practices for building scalable and secure AWS infrastructure. Essential knowledge for every AWS and DevOps Engineer!

AWS VPC Peering: Secure and Private Communication Between Virtual Private Clouds

Introduction

In modern cloud infrastructure, networking plays a critical role in building secure, scalable, and highly available applications. As organizations expand their workloads across multiple environments, they often need to establish private communication between different Amazon Virtual Private Clouds (VPCs).
AWS VPC Peering is a networking feature that allows two Virtual Private Clouds to communicate with each other privately using their private IP addresses, without requiring traffic to travel over the public internet.
VPC Peering is commonly used in multi-tier architectures, microservices environments, shared services architectures, and enterprise cloud infrastructure.

What is AWS VPC Peering?

AWS VPC Peering is a networking connection between two VPCs that enables private IPv4 or IPv6 communication between resources.
A VPC peering connection can be established between:
  • Two VPCs within the same AWS account.
  • VPCs across different AWS accounts.
  • VPCs in different AWS Regions (inter-Region VPC Peering).
Once the connection is established and properly configured, resources such as EC2 instances, databases, and application servers can communicate using private IP addresses.

How Does VPC Peering Work?

VPC Peering works by creating a private networking connection between two VPCs.
For example:
  • VPC-A: 10.0.0.0/16
  • VPC-B: 192.168.0.0/16
Suppose VPC-A hosts an application server and VPC-B hosts a database server.
By establishing a VPC Peering connection, the application server in VPC-A can communicate privately with the database server in VPC-B.
However, creating a peering connection alone is not sufficient. We must also configure route tables, security groups, and network access control lists (NACLs) appropriately.

Architecture Overview

Example architecture:
VPC-A (10.0.0.0/16)
  • Public Subnet
  • Private Subnet
  • EC2 Application Server  | | VPC Peering Connection | 
VPC-B (192.168.0.0/16)
  • Private Subnet
  • Database Server
  • Internal Services
Communication happens through private IP addresses without requiring public internet access.

Step-by-Step Implementation of AWS VPC Peering

Step 1: Create Two VPCs
Create two VPCs in the AWS VPC console.
  • VPC-A: 10.0.0.0/16
  • VPC-B: 192.168.0.0/16
Ensure that both VPCs have non-overlapping CIDR blocks.
Step 2: Create a VPC Peering Connection
  1. Open the AWS Management Console.
  1. Navigate to VPC.
  1. Select Peering Connections.
  1. Click Create Peering Connection.
  1. Select the requester VPC.
  1. Select the accepter VPC.
  1. Click Create Peering Connection.
Step 3: Accept the Peering Request
Navigate to Peering Connections, select the pending connection, and click Actions → Accept Request.
The peering connection will become active after acceptance.
Step 4: Update Route Tables
This is one of the most important configuration steps.
In VPC-A's route table, add:
  • Destination: 192.168.0.0/16
  • Target: VPC Peering Connection ID (pcx-xxxxxxxx)
In VPC-B's route table, add:
  • Destination: 10.0.0.0/16
  • Target: VPC Peering Connection ID (pcx-xxxxxxxx)
These routes allow traffic to reach the remote VPC through the peering connection.
Step 5: Configure Security Groups
Update the security groups to allow the required application traffic.
For example:
  • Allow SSH (TCP 22) only from trusted administrative sources, if required.
  • Allow application traffic on the required application port.
  • Allow database traffic, such as TCP 3306 for MySQL, from the application server's security group or private CIDR, as appropriate.
Follow the principle of least privilege. Do not open unnecessary ports.
Step 6: Test Connectivity
Launch EC2 instances in both VPCs and test connectivity using private IP addresses.
Example:
ping 192.168.1.10
You can also test a specific TCP port:
nc -zv 192.168.1.10 3306
Note: ICMP traffic must be permitted by the relevant security group and network ACLs for ping to work.

Important Limitations of VPC Peering

Before implementing VPC Peering in production, understand these limitations:
  1. No Transitive Routing: If VPC-A is peered with VPC-B, and VPC-B is peered with VPC-C, VPC-A cannot automatically communicate with VPC-C through VPC-B.
  1. Non-Overlapping CIDR Blocks: VPCs cannot establish a peering connection if their IPv4 CIDR blocks overlap.
  1. No Edge-to-Edge Routing: VPC Peering does not support using another VPC's VPN, Direct Connect, or internet gateway as a transit path.
  1. Manual Route Configuration: Appropriate routes must be configured in both VPCs.
  1. Security Configuration: Security groups, NACLs, and DNS settings must be reviewed according to the communication requirements.

VPC Peering vs AWS Transit Gateway

VPC Peering is suitable for connecting a small number of VPCs directly.
AWS Transit Gateway is a better choice when an organization needs centralized connectivity across multiple VPCs, accounts, or on-premises networks.
For example:
  • VPC Peering: Direct connectivity between two VPCs.
  • Transit Gateway: Centralized hub-and-spoke networking architecture.

Real-World Use Cases

  1. Application and Database Communication: Connect application servers in one VPC to database servers in another VPC.
  1. Development and Production Environments: Enable controlled private communication between separate environments.
  1. Shared Services Architecture: Allow multiple VPCs to access shared services such as monitoring, logging, and internal DNS infrastructure.
  1. Multi-Account AWS Architecture: Establish private communication between VPCs owned by different AWS accounts.

Best Practices for Production Environments

  • Always use non-overlapping CIDR blocks.
  • Follow the principle of least privilege.
  • Keep route tables organized and documented.
  • Monitor network traffic using VPC Flow Logs.
  • Avoid unnecessary inbound and outbound rules.
  • Use AWS Transit Gateway when centralized multi-VPC connectivity is required.
  • Regularly review network architecture and security configurations.

Conclusion

AWS VPC Peering is a powerful networking solution for establishing secure, private communication between two Amazon VPCs.
As a DevOps or Cloud Engineer, understanding VPC Peering is essential for designing scalable cloud architectures, managing application connectivity, and troubleshooting networking issues in real-world production environments.
A well-designed AWS networking architecture is not just about connectivity; it is about security, scalability, reliability, and operational efficiency.
Build secure networks. Design scalable infrastructure. Think like a Cloud Engineer.
#AWS #AWSSolutionsArchitect #VPCPeering #CloudComputing #DevOps #Networking #AmazonVPC #CloudEngineer #AWSNetworking #InfrastructureAsCode
Any opinions in this article are those of the individual author and may not reflect the opinions of AWS.
Enjoyed reading this content? Let the author know!

Your likes, comments, shares, and saves help creators reach more builders.

Loading recommendations

Loading article