Fermin Perdomo

Senior Full Stack Engineer | PHP | JavaScript

Sometimes you need to connect two VPCs in AWS. In this article, I will explain how to implement that in four simple steps.

Step-by-Step GuideStep 1: Create VPC Peering Connection
  • Go to: AWS Console → VPC DashboardPeering Connections → Click “Create Peering Connection”.

  • Fill in the details:

    • Name tag (optional): e.g., VPC-A-to-VPC-B.

    • VPC Requester:

      • Select the Requester VPC (your current VPC).

    • VPC Accepter:

      • Same account: Choose from dropdown.

      • Another account: Enter Account ID and VPC ID manually.

  • Click “Create Peering Connection”.

  • Step 2: Accept the Peering Connection
  • Same account:

    1. In VPC → Peering Connections, select the new connection.

    2. Click “Actions → Accept Request”.

  • Different account:

    1. The owner of the Accepter VPC must log into their AWS account.

    2. Navigate to VPC → Peering Connections.

    3. Find the pending request and click “Accept Request”.

  • Step 3: Update Route TablesYou must allow traffic between VPCs by updating their route tables.
  • Go to VPC → Route Tables.

  • For each VPC:

    • Select the relevant Route Table.

    • Click “Routes” → Edit routes → Add route:

      • Destination: The CIDR block of the peer VPC.

      • Target: The Peering Connection ID.

    • Click “Save routes”.

  • Repeat this for the other VPC’s route table.Step 4: Update Security Groups (Optional but likely needed)
  • Go to EC2 → Security Groups.

  • Edit the inbound rules to allow traffic from the CIDR of the peer VPC.

  • Example:
  • Type: All traffic (or specific port like HTTP, SSH)

  • Source: <peer VPC CIDR>

  • Do this on both sides.

    Let me integrate VPCs for you. Get a free quote here.

    Credits:
    Image author:
    Designed by stories / Freepik