Menu
Amazon Elastic Compute Cloud
API Reference (API Version 2016-11-15)

CreateVpcPeeringConnection

Requests a VPC peering connection between two VPCs: a requester VPC that you own and a peer VPC with which to create the connection. The peer VPC can belong to another AWS account. The requester VPC and peer VPC cannot have overlapping CIDR blocks.

The owner of the peer VPC must accept the peering request to activate the peering connection. The VPC peering connection request expires after 7 days, after which it cannot be accepted or rejected.

If you try to create a VPC peering connection between VPCs that have overlapping CIDR blocks, the VPC peering connection status goes to failed.

Request Parameters

The following parameters are for this specific action. For more information about required and optional parameters that are common to all actions, see Common Query Parameters.

DryRun

Checks whether you have the required permissions for the action, without actually making the request, and provides an error response. If you have the required permissions, the error response is DryRunOperation. Otherwise, it is UnauthorizedOperation.

Type: Boolean

Required: No

PeerOwnerId

The AWS account ID of the owner of the peer VPC.

Default: Your AWS account ID

Type: String

Required: No

PeerVpcId

The ID of the VPC with which you are creating the VPC peering connection.

Type: String

Required: No

VpcId

The ID of the requester VPC.

Type: String

Required: No

Response Elements

The following elements are returned by the service.

requestId

The ID of the request.

Type: String

vpcPeeringConnection

Information about the VPC peering connection.

Type: VpcPeeringConnection object

Errors

For information about the errors that are common to all actions, see Common Client Errors.

Examples

Example 1

This example requests a peering connection between your VPC (vpc-1a2b3c4d), and a VPC (vpc-a1b2c3d4) that belongs to AWS account 123456789012.

Sample Request

https://ec2.amazonaws.com/?Action=CreateVpcPeeringConnection
&VpcId=vpc-1a2b3c4d
&PeerVpcId=vpc-a1b2c3d4
&PeerOwnerId=123456789012
&AUTHPARAMS           

Sample Response

<CreateVpcPeeringConnectionResponse xmlns="http://ec2.amazonaws.com/doc/2016-11-15/">
 <requestId>7a62c49f-347e-4fc4-9331-6e8eEXAMPLE</requestId>
 <vpcPeeringConnection>
  <vpcPeeringConnectionId>pcx-73a5401a</vpcPeeringConnectionId>
    <requesterVpcInfo>
     <ownerId>777788889999</ownerId>
     <vpcId>vpc-vpc-1a2b3c4d</vpcId>
     <cidrBlock>10.0.0.0/28</cidrBlock>
     <peeringOptions>
       <allowEgressFromLocalClassicLinkToRemoteVpc>false</allowEgressFromLocalClassicLinkToRemoteVpc>
       <allowEgressFromLocalVpcToRemoteClassicLink>false</allowEgressFromLocalVpcToRemoteClassicLink>
       <allowDnsResolutionFromRemoteVpc>false</allowDnsResolutionFromRemoteVpc>
     </peeringOptions>
    </requesterVpcInfo>
    <accepterVpcInfo>
      <ownerId>123456789012</ownerId>
      <vpcId>vpc-a1b2c3d4</vpcId>
    </accepterVpcInfo>
    <status>
     <code>initiating-request</code>
     <message>Initiating Request to 123456789012</message>
    </status>
    <expirationTime>2014-02-18T14:37:25.000Z</expirationTime>
    <tagSet/>
 </vpcPeeringConnection>
</CreateVpcPeeringConnectionResponse>

Example 2

This example requests a peering connection between your VPCs vpc-1a2b3c4d and vpc-11122233.

Sample Request

https://ec2.amazonaws.com/?Action=CreateVpcPeeringConnection
&VpcId=vpc-1a2b3c4d
&PeerVpcId=vpc-11122233
&AUTHPARAMS

See Also

For more information about using this API in one of the language-specific AWS SDKs, see the following: