# Virtual Private Cloud (VPC) Peering

VPC [peering ](https://en.wikipedia.org/wiki/Peering)is a networking connection between two VPCs enabling traffic to be routed between them. When you use VPC peering, instances in the VPCs communicate with each other as if they are in the same network. The VPCs can be in different regions (also known as Inter-Region VPC peering connections).

VPC peering facilitates the transfer of data. For example, if you have more than one AWS account, you can peer the VPCs across those accounts and create a file-sharing network.

This procedure describes how to peer two VPCs, using subnet routes, and how to manage the peering connections and routes.

## Enable and peer VPCs

Enable VPCs for peering:

We will be referring following steps to peer 2 VPCs **VPC-A** and **VPC-B**.

1. In the DuploCloud Portal, navigate to **Administrator** -> **Infrastructure**. The **Infrastructure** page displays. In this example, the Infrastructures are named **VPC-A** and **VPC-B**.
2. From the **Name** column, select the first Infrastructure (**VPC-A**) for which to enable peering. **VPC-A** and its defined subnet routes are displayed.
3. Click the **Peering** tab.<br>

   <figure><img src="https://2471407984-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F68cb0s9ce5UIUKWPuYs8%2Fuploads%2FUiew67RZBptEhiBK9IqD%2FAWS_VPC_Peering_1.png?alt=media&#x26;token=4e11a401-3015-4b40-b56d-24f1eea47256" alt=""><figcaption><p><strong>VPC Peering</strong> page for Infrastructure <strong>VPC-A</strong></p></figcaption></figure>
4. From the **Select a VPC to peer with VPCA** list box, select the VPC that you want to peer with **VPC-A**. In this example, we select **VPC-B**.
5. Select the **Is Peered** checkbox.
6. Click **Save**.<br>

   <figure><img src="https://2471407984-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F68cb0s9ce5UIUKWPuYs8%2Fuploads%2FjCNurfV2pjLkeSUGmm9v%2FAWS_VPC_Peering_2.png?alt=media&#x26;token=506b3efa-8e57-40fa-8116-e0e7fcba4106" alt=""><figcaption><p>Saving <strong>VPC-A</strong> and <strong>VPC-B</strong> peering association</p></figcaption></figure>
7. Repeat steps 1 to 6 for **VPC-B** Infrastructure to configure bidirectional peering.

## Select subnet routes for VPC peering

Now that your two VPCs (**VPC-A** and **VPC-B**) are connected, define the subnet routes that the VPCs use for communication.

To begin, on the VPC Peering page for the first VPC that you set up (**VPC-A**), click **Peer again**. The **Infrastructure** page displays.

1. Select the Infrastructure (**VPC-A**) containing the first VPC that you [enabled ](#enable-and-associate-vpcs-for-peering)for peering.
2. Select the **Peering** tab.
3. Select the **Select a VPC to peer with VPCA** list box. The second VPC (**VPC-B**) displays in the list box and the **Is Peered** checkbox is selected, indicating that you previously connected the first VPC (**VPC-A**) with the second VPC (**VPC-B**) for peering.
4. Select the subnet routes that you want to define for VPC peering communication between the two VPCs (**VPC-A** and **VPC-B**). In this example, we select the checkboxes for subnet routes **vpc-B-a-private** and **vpc-B-a-public**.<br>

   <figure><img src="https://2471407984-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F68cb0s9ce5UIUKWPuYs8%2Fuploads%2Fj2XFVNSxK7wQtJ9XzMIo%2FAWS_VPC_Peering_3.png?alt=media&#x26;token=5670ef5d-2f20-4fd6-bc9d-cec79484c247" alt=""><figcaption><p>Defining subnet routes for use by VPC-A and VPC-B</p></figcaption></figure>
5. Click **Save**.

Click **Peer again** and repeat the numbered procedure above to peer the **VPC-B** Infrastructure.

## Verify peering between associated VPCs

Confirm that your two VPCs are enabled for peering, are connected with each other, and have subnet routes defined for communication.

1. In the DuploCloud Portal, navigate to **Administrator** -> **Infrastructure**. The **Infrastructure** page displays.
2. Select one of the Infrastructures containing a VPC that you previously [enabled ](#enable-and-associate-vpcs-for-peering)for peering and for which you defined [subnet routes](#select-subnets-to-use-vpc-peering). In this example, we select **VPC-A**.
3. Click the **Peering** tab.<br>

   <figure><img src="https://2471407984-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F68cb0s9ce5UIUKWPuYs8%2Fuploads%2F5zSP5DSK3KSvwiJKGXt0%2FScreenshot%20(150).png?alt=media&#x26;token=74c791ab-fe5a-4a03-afb0-1a703032f802" alt=""><figcaption><p><strong>VPC-A</strong> is peered with <strong>VPC-B</strong> and subnet routes are defined.</p></figcaption></figure>
4. In the **Select a VPC to peer with VPC-A** list box, select **VPC-B** to confirm that **VPC-B** is peered with **VPC-A** and uses the subnet routes you defined. The name of the second VPC (**VPC-B**) displays in the list box and the **Is Peered** checkbox is selected. The subnet routes that you selected are displayed as checked.
5. Click **Save**.

## Configure Security Group rules for Tenant VPC zones

To maintain accessibility, add Security Group rules for Tenant VPC zones:

1. In the DuploCloud Portal, navigate to **Administrator** -> **Infrastructure**.
2. Select the Infrastructure from the **Name** column.
3. Click the **Security Group Rules** tab.<br>

   <figure><img src="https://2471407984-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F68cb0s9ce5UIUKWPuYs8%2Fuploads%2FFE6NDVBVf2lSOZ2LAlzP%2FScreenshot%20(149).png?alt=media&#x26;token=582e30ca-9a39-49a9-906b-eebb8cf0f586" alt=""><figcaption><p><strong>Security Group Rules</strong> tab on Infrastructure page in the DuploCloud Portal</p></figcaption></figure>
4. Click **Add**. The **Add Tenant Security** pane opens.<br>

   <div align="left"><figure><img src="https://2471407984-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F68cb0s9ce5UIUKWPuYs8%2Fuploads%2FPCdiknf47UsqatNlVCEz%2FAWS_SG_Add_Tenant_Security.png?alt=media&#x26;token=d718ed4c-70fa-4b34-8521-035a70ebe6b1" alt=""><figcaption><p><strong>Add Tenant Security</strong> pane</p></figcaption></figure></div>
5. Define the rule for your **Port Range** and click **Add**.

## Delete subnet routes for peered VPCs

Delete subnet routes that you defined for VPC peer-to-peer communication:

1. In the DuploCloud Portal, navigate to **Administrator** -> **Infrastructure**. The **Infrastructure** page displays.
2. Select one of the Infrastructures containing a VPC that you previously [enabled ](#enable-and-associate-vpcs-for-peering)for peering and for which you defined [subnet routes](#select-subnets-to-use-vpc-peering). Continuing the example above, in this case, we select **VPC-A**.
3. Click the **Peering** tab.<br>

   <figure><img src="https://2471407984-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F68cb0s9ce5UIUKWPuYs8%2Fuploads%2FUiew67RZBptEhiBK9IqD%2FAWS_VPC_Peering_1.png?alt=media&#x26;token=4e11a401-3015-4b40-b56d-24f1eea47256" alt=""><figcaption><p><strong>VPC Peering</strong> page for Infrastructure <strong>VPC-A</strong></p></figcaption></figure>
4. In the **Select a VPC to peer with VPC-A** list box, select the corresponding VPC (in this case, VPC-B) The peered VPC (**VPC-B**) displays and the **Is Peered** checkbox is selected along with the associated subnet routes defined for communication.
5. Uncheck subnet routes you want to remove. Using the **CTRL** key, you can select multiple checkboxes and clear them with a single click. In this example, we remove the subnet route **VPC-B-A-private** by clearing its checkbox.<br>

   <figure><img src="https://2471407984-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F68cb0s9ce5UIUKWPuYs8%2Fuploads%2FyCB33vOIS3MXvTU6qYDN%2FAWS_VPC_Peering_5.png?alt=media&#x26;token=407d26e7-6292-4be0-8461-7ad3d2a71b1b" alt=""><figcaption><p>Deleting the <strong>vpc-b-A-private</strong> subnet route from the <strong>VPC-A</strong>/<strong>VPC-B</strong> peering connection</p></figcaption></figure>
6. Click **Save**. The subnet route **vpc-b-A-private** has been removed for **VPC-A**/**VPC-B** peering.
7. Optionally, confirm the deletion by [verifying peering between associated PVCs](#verify-peering-between-associated-vpcs).

## Delete peered VPCs

Delete the peering connection between VPCs:

1. In the DuploCloud Portal, navigate to **Administrator** -> **Infrastructure**. The **Infrastructure** page displays.
2. Select one of the Infrastructures containing a VPC that you previously [enabled ](#enable-and-associate-vpcs-for-peering)for peering and for which you defined [subnet routes](#select-subnets-to-use-vpc-peering). Continuing the example above, in this case, we select **VPC-A**.
3. Click the **Peering** tab. The **VPC Peering** page displays for **VPC-A**.<br>

   <figure><img src="https://2471407984-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F68cb0s9ce5UIUKWPuYs8%2Fuploads%2FUiew67RZBptEhiBK9IqD%2FAWS_VPC_Peering_1.png?alt=media&#x26;token=4e11a401-3015-4b40-b56d-24f1eea47256" alt=""><figcaption><p>Click the <strong>Peering</strong> tab. The <strong>VPC Peering</strong> page displays for <strong>VPC-A</strong>.</p></figcaption></figure>
4. Select the **Choose VPC** list box. The peered VPC (**VPC-B**) displays and the **Is Peered** checkbox is selected along with the associated subnet routes defined for communication.
5. Clear the **Is Peered** checkbox.<br>

   <figure><img src="https://2471407984-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F68cb0s9ce5UIUKWPuYs8%2Fuploads%2FCJxPyqVHv0A9VrCkCiCa%2FAWS_VPC_Peering_6.png?alt=media&#x26;token=11900676-e288-40be-a049-be13d76a2d2b" alt=""><figcaption><p>After the <strong>Is Peered</strong> checkbox is cleared, the <strong>VPC-A</strong>/<strong>VPC-B</strong> peering connection is deleted when you click <strong>Save</strong>.</p></figcaption></figure>
6. Click **Save**. The **Select Subnets** list no longer displays and the peering connection between **VPC-A** and **VPC-B** has been removed.
7. Optionally, confirm the deletion by [verifying peering between associated VPCs](#verify-peering-between-associated-vpcs).
