VPC
AWS
Peering

How to Set Up VPC Peering in AWS: A Step-by-Step Guide

Ashwani Paliwal
June 20, 2024

Virtual Private Cloud (VPC) peering in AWS allows you to connect two VPCs, enabling resources in both VPCs to communicate with each other as if they are within the same network. This is particularly useful for organizations looking to efficiently manage network traffic across different regions or accounts. In this blog, we will walk you through the process of setting up VPC peering in AWS.

Why Use VPC Peering?

Before we dive into the setup process, let's understand why you might want to use VPC peering:

  1. Seamless Connectivity: VPC peering allows for seamless and secure connectivity between VPCs.
  2. Cost-Effective: Unlike VPN or Direct Connect, VPC peering is often more cost-effective as it avoids additional data transfer charges between VPCs within the same region.
  3. Resource Sharing: Enables easy sharing of resources such as databases, applications, and other services between different VPCs.

Prerequisites

Before you start, ensure you have the following:

  • An AWS account with sufficient permissions to create and manage VPCs and peering connections.
  • Two VPCs with non-overlapping CIDR blocks.

Step-by-Step Guide to Setting Up VPC Peering

Step 1: Sign In to AWS Management Console

  1. Sign in to your AWS Management Console.
  2. Navigate to the VPC Dashboard.

Step 2: Create VPCs (If Not Already Created)

If you haven't already created the VPCs you want to peer, follow these steps:

  1. In the VPC Dashboard, click on Create VPC.
  2. Provide a Name and CIDR block (e.g., 10.0.0.0/16).
  3. Click Create.
  4. Repeat the steps for the second VPC with a different CIDR block (e.g., 10.1.0.0/16).

Step 3: Create a VPC Peering Connection

  1. In the VPC Dashboard, select Peering Connections in the left navigation pane.
  2. Click Create Peering Connection.
  3. Provide a Name for the peering connection.
  4. Select your Requester VPC (the VPC initiating the request).
  5. Select your Accepter VPC. This can be:some text
    • Another VPC in your account.
    • A VPC in another AWS account (you’ll need the AWS account ID).
  6. Click Create Peering Connection.

Step 4: Accept the VPC Peering Request

  1. Navigate to the Peering Connections page.
  2. Find the peering connection you just created. Its status will be Pending Acceptance.
  3. Select the peering connection and click Actions, then Accept Request.
  4. Confirm the acceptance.

Step 5: Update Route Tables

To enable traffic between the VPCs, you need to update the route tables.

  1. Go to the Route Tables section in the VPC Dashboard.
  2. Select the route table associated with the first VPC.
  3. Click on the Routes tab and then Edit Routes.
  4. Add a route with:some text
    • Destination: CIDR block of the second VPC.
    • Target: The VPC peering connection.
  5. Click Save routes.
  6. Repeat the steps for the route table of the second VPC, adding a route for the first VPC.

Step 6: Update Security Groups

  1. Navigate to the Security Groups section.
  2. Select the security group associated with your VPC.
  3. Click on the Inbound Rules tab and then Edit Inbound Rules.
  4. Add a rule allowing traffic from the CIDR block of the peered VPC.
  5. Click Save rules.
  6. Repeat the steps for the security group of the second VPC.

Step 7: Verify the Connection

  1. Launch instances in both VPCs if not already done.
  2. Verify connectivity by pinging the instance in the peered VPC or using other network diagnostic tools.

Conclusion

Setting up VPC peering in AWS involves creating and accepting a peering connection, updating route tables, and configuring security groups to allow traffic between the VPCs. Following this guide will help you establish a seamless connection between your VPCs, enabling efficient and secure communication.


SecOps Solution is an award-winning agent-less Full-stack Vulnerability and Patch Management Platform that helps organizations identify, prioritize, and remediate security vulnerabilities and misconfigurations in seconds.

To schedule a demo, just pick a slot that is most convenient for you.

Related Blogs