Creating a VPC Peering Connection

You can create a VPC peering connection between one of your Virtual Private Clouds (VPCs) and another VPC to enable communication between them.

This action sends a request from your VPC to connect to another VPC, which can belong to you or another account.

The owner of the other VPC must accept the request to create the connection. For more information, see Accepting a VPC Peering Connection.

  • If you use Cockpit v1 to create a VPC peering connection between two VPCs that belong to your account, the request is automatically accepted.

  • A peering connection between two VPCs works both ways. Therefore, you do not need to create a B-to-A connection if an A-to-B connection is already created and accepted.

Creating a VPC Peering Connection Using Cockpit

Before you begin:

  • Create a VPC. For more information, see Creating a VPC.

  • Ensure that you have the ID of the VPC you want to peer with.

  • If the accepter VPC belongs to another account, ensure that you have the account ID of the owner.

  1. Click VPC > VPC Peering Connections.

  2. Click Create .
    The CREATE VPC PEERING CONNECTION dialog box appears.

  3. (optional) In the Name field, type a name for the VPC peering connection.

    This action adds a Name tag of 255 characters maximum. You can use any character, including accented letters.

  4. From the Source list, select the VPC you want to send the request from.

  5. If you are peering two VPCs in your own account:

    1. Leave the Account ID box unchecked.

    2. Select the VPC you want to connect with.

  6. If you are peering one of your VPCs with a VPC which belongs to another account:

    1. Check the Account ID box.

    2. In the Account ID field, type the account ID of the owner of the VPC you want to connect with.

    3. In the VPC ID field, type the ID of the VPC you want to connect with.

  7. Click Create to validate.

    Peered VPCs must not have overlapping CIDR blocks. Otherwise, the connection is automatically in the failed state. For more information, see About VPC Peering Connections.

    The VPC peering connection appears in the VPC peering connections page.

Creating a VPC Peering Connection Using AWS CLI

Before you begin:

  • Create a VPC. For more information, see Creating a VPC.

  • Ensure that you have the ID of the VPC you want to peer with.

  • If the accepter VPC belongs to another account, ensure that you have the account ID of the owner.

To create a VPC peering connection, use the create-vpc-peering-connection command following this syntax:

Request sample
$ aws ec2 create-vpc-peering-connection \
    --profile YOUR_PROFILE \
    --vpc-id vpc-1a2b3c4d \
    --peer-vpc-id vpc-11122233 \
    --peer-owner-id 888877776666 \
    --endpoint https://fcu.eu-west-2.outscale.com

This command contains the following attributes that you need to specify:

  • (optional) profile: The named profile you want to use, created when configuring AWS CLI. For more information, see Installing and Configuring AWS CLI.

  • vpc-id: The ID of the VPC you send the request from.

  • peer-vpc-id: The ID of the VPC you want to connect with.

    Peered VPCs must not have overlapping CIDR blocks. Otherwise, the connection is automatically in the failed state. For more information, see About VPC Peering Connections.

  • (optional) peer-owner-id: The account ID of the owner of the VPC you want to connect with. By default, your account ID.

  • endpoint: The endpoint corresponding to the Region you want to send the request to.

The create-vpc-peering-connection command returns the following elements:

  • VpcPeeringConnection: Information about the VPC peering connection you requested. This element contains the following information:

    • AccepterVpcInfo: Information about the VPC you want to connect with. This element contains the following information:

      • CidrBlock: The range of IPs of the VPC, in CIDR notation.

      • OwnerId: The account ID of the owner of the VPC.

      • VpcId: The ID of the VPC.

    • RequesterVpcInfo: Information about the VPC you send the request from. This element contains the following information:

      • CidrBlock: The range of IPs of the VPC, in CIDR notation.

      • OwnerId: The account ID of the owner of the VPC.

      • VpcId: The ID of the VPC.

    • Status: Information about the state of the VPC peering connection. This element contains the following information:

      • Code: The state of the VPC peering connection (pending-acceptance | failed). For more information, see About VPC Peering Connections > Lifecycle.

      • Message: Additional information about the state of the VPC peering connection.

    • Tags: One or more tags associated with the VPC peering connection. This element contains the following information:

      • Key: The key of the tag.

      • Value: The value of the tag.

    • VpcPeeringConnectionId: The ID of the VPC peering connection.

Result sample
{
    "VpcPeeringConnection": {
        "AccepterVpcInfo": {
            "CidrBlock": "175.0.0.0/28",
            "OwnerId": "888877776666",
            "VpcId": "vpc-11122233"
        },
        "RequesterVpcInfo": {
            "CidrBlock": "10.0.0.0/28",
            "OwnerId": "444455556666",
            "VpcId": "vpc-1a2b3c4d"
        },
        "Status": {
            "Code": "pending-acceptance",
            "Message": "Pending acceptance by 888877776666"
        },
        "Tags": [],
        "VpcPeeringConnectionId": "pcx-111aaa11"
    }
}

A connection request is sent from your VPC to the accepter VPC.

Related Pages

Corresponding API Method

AWS™ and Amazon Web Services™ are trademarks of Amazon Technologies, Inc or its affiliates in the United States and/or other countries.