All Products
Search
Document Center

Virtual Private Cloud:CreateVpcPeerConnection

Last Updated:Oct 29, 2026

Invokes the CreateVpcPeerConnection operation to create a VPC peering connection.

Operation description

Before you create a VPC peering connection, take note of the following items:

  • CreateVpcPeerConnection is an asynchronous operation. After you call this operation, the system returns an InstanceId, but the VPC peering connection is not created yet and the creation task is still running in the background. You can call GetVpcPeerConnectionAttribute to query the status of the VPC peering connection.
    • If the VPC peering connection is in the Creating state, the VPC peering connection is being created.

    • If the VPC peering connection is in the Activated state, the VPC peering connection is created.

    • If the VPC peering connection is in the Accepting state, the VPC peering connection is created across accounts and must be accepted by the acceptor.

  • You cannot call the CreateVpcPeerConnection operation to concurrently create VPC peering connections in the same VPC.

When you create a VPC peering connection, the system automatically activates Cloud Data Transfer (CDT) for non-cross-border data transfer.

Try it now

Try this API in OpenAPI Explorer, no manual signing needed. Successful calls auto-generate SDK code matching your parameters. Download it with built-in credential security for local usage.

Test

RAM authorization

The table below describes the authorization required to call this API. You can define it in a Resource Access Management (RAM) policy. The table's columns are detailed below:

  • Action: The actions can be used in the Action element of RAM permission policy statements to grant permissions to perform the operation.

  • API: The API that you can call to perform the action.

  • Access level: The predefined level of access granted for each API. Valid values: create, list, get, update, and delete.

  • Resource type: The type of the resource that supports authorization to perform the action. It indicates if the action supports resource-level permission. The specified resource must be compatible with the action. Otherwise, the policy will be ineffective.

    • For APIs with resource-level permissions, required resource types are marked with an asterisk (*). Specify the corresponding Alibaba Cloud Resource Name (ARN) in the Resource element of the policy.

    • For APIs without resource-level permissions, it is shown as All Resources. Use an asterisk (*) in the Resource element of the policy.

  • Condition key: The condition keys defined by the service. The key allows for granular control, applying to either actions alone or actions associated with specific resources. In addition to service-specific condition keys, Alibaba Cloud provides a set of common condition keys applicable across all RAM-supported services.

  • Dependent action: The dependent actions required to run the action. To complete the action, the RAM user or the RAM role must have the permissions to perform all dependent actions.

Action

Access level

Resource type

Condition key

Dependent action

vpc:CreateVpcPeerConnection

create

*All Resource

*

None None

Request parameters

Parameter

Type

Required

Description

Example

RegionId

string

Yes

The ID of the region where you want to create a VPC peering connection.

You can invoke the DescribeRegions operation to query region IDs.

cn-hangzhou

VpcId

string

Yes

The ID create a VPC that acts as the initiator create a VPC peering connection.

vpc-bp1gsk7h12ew7oegk****

AcceptingAliUid

integer

Yes

The ID of the Alibaba Cloud account to which the acceptor of the VPC peering connection belongs.

  • If you enter your own Alibaba Cloud account ID, a same-account VPC peering connection is created.

  • If you enter the ID of another Alibaba Cloud account, a cross-account VPC peering connection is created.

Note

If the acceptor account is a Resource Access Management (RAM) user, you must enter the ID of the Alibaba Cloud account to which the RAM user belongs in AcceptingAliUid.

1210123456123456

AcceptingRegionId

string

Yes

The ID of the region where the acceptor of the VPC peering connection is deployed.

  • To create an intra-region VPC peering connection, enter the same region ID as the initiator.

  • To create an inter-region VPC peering connection, enter a region ID different from that of the initiator.

cn-hangzhou

AcceptingVpcId

string

Yes

The ID of the VPC that acts as the acceptor of the VPC peering connection.

vpc-bp1vzjkp2q1xgnind****

Name

string

No

The name of the VPC peering connection. The name must be 2 to 128 characters in length. It must start with a letter or a Chinese character and can contain digits, underscores (_), and hyphens (-).

vpcpeer

Description

string

No

The description of the VPC peering connection. The description must be 2 to 256 characters in length. It must start with a letter or a Chinese character and cannot start with http:// or https://.

description

DryRun

boolean

No

Specifies whether to perform only a dry run for this request. Valid values:

  • true: performs a dry run and does not create a VPC peering connection. The system checks whether required parameters are specified, the request format, and service limits. If the request fails the dry run, the corresponding error is returned. If the request passes the dry run, the DryRunOperation error code is returned.

  • false (default): sends a Normal request. If the request passes the dry run, an HTTP 2xx status code is returned and the operation is performed.

false

ClientToken

string

No

The client token that is used to ensure the idempotence of the request.

You can use the client to generate the token, but you must make sure that the token is unique among different requests. The token can contain only ASCII characters and cannot exceed 64 characters in length.

Note

If you do not specify this parameter, the system automatically uses the RequestId of the API request as the ClientToken. The RequestId of each API request may be different.

02fb3da4-130e-11e9-8e44-001****

ResourceGroupId

string

No

The ID of the resource group.

For more information about resource groups, see What is a resource group?.

rg-acfmxazb4ph6aiy****

Bandwidth

integer

No

The bandwidth of the VPC peering connection. Unit: Mbit/s. The value must be a positive integer.

Note

If you want to specify this parameter, make sure that you are creating an inter-region peering connection.

100

LinkType

string

No

The link type.

Valid values: Platinum and Gold. Default value: Gold.

Note

If you want to specify this parameter, make sure that you are creating an inter-region peering connection.

Gold

Tag

array<object>

No

The tag information.

object

No

The tag information.

Key

string

No

The tag key of the resource. You must specify at least one tag key and can specify up to 20 tag keys. The tag key cannot be an empty string.

The tag key can be up to 128 characters in length. It cannot start with aliyun or acs:, and cannot contain http:// or https://.

FinanceDept

Value

string

No

The tag value of the resource. You must specify at least one tag value and can specify up to 20 tag values. The tag value can be an empty string.

The tag value can be up to 128 characters in length. It cannot start with aliyun or acs:, and cannot contain http:// or https://.

FinanceJoshua

Response elements

Element

Type

Description

Example

object

The request ID.

InstanceId

string

The instance ID of the created VPC peering connection.

pcc-lnk0m24khwvtkm****

RequestId

string

The request ID.

54B48E3D-DF70-471B-AA93-08E683A1B45

Examples

Success response

JSON format

{
  "InstanceId": "pcc-lnk0m24khwvtkm****",
  "RequestId": "54B48E3D-DF70-471B-AA93-08E683A1B45"
}

Error codes

HTTP status code

Error code

Error message

Description

400 OperationFailed.CdtNotOpened The operation failed because the Cdt service is not opened. The operation failed because CDT is not activated.
400 OperationFailed.CrossBorderCdtNotOpened The operation failed because the CrossBorderCdt service is not opened. The Alibaba Cloud cross-border data transfer feature is not enabled.
400 IncorrectStatus.Vpc The status of %s [%s] is incorrect. The status of the initiator VPC instance is incorrect.
400 IncorrectStatus.AcceptingVpc The status of %s [%s] is incorrect. The receiving VPC status is incorrect.
400 ResourceAlreadyExist.RouterInterface The specified resource of %s already exists. The specified router interface already exists.
400 ResourceAlreadyExist.VpcPeer The specified resource of %s already exists. The specified VPC peering connection already exists.
400 OperationDenied.CloudBoxExistsInVpc The operation is not allowed because the CloudBox device exists in vpc. A cloud box instance exists in the initiator VPC, so it is not allowed to create a VpcPeer instance.
400 OperationDenied.CloudBoxExistsInAcceptingVpc The operation is not allowed because the CloudBox device exists in accepting vpc. Cloud box instances exist in the receiving end VPC, so VpcPeer instances are not allowed to be created.
400 QuotaExceeded.VpcPeerCountPerVpc The quota of %s is exceeded, usage %s/%s. The number of VPC peering connections to the VPC has reached the upper limit.
400 UnsupportedRegion The feature of %s is not supported in the region of %s. VPC peering connections are not supported in this region.
400 QuotaExceeded.VpcPeerCountPerUserPerRegion The quota of %s is exceeded, usage %s/%s. The number of VpcPeer instances in a region exceeds the threshold.
400 IncorrectBusinessStatus.VpcPeer The business status of %s [%s] is incorrect. The current instance status is abnormal and the current operation is not allowed.
400 OperationFailed.NotExist.ResourceGroup The operation failed because the resource group does not exist. The operation failed because the resource group does not exist.
400 OperationFailed.AcceptUserCdtNotOpened The operation failed because the Cdt service of accept user is not opened. The operation failed because CDT is not activated for the peer.
400 OperationFailed.AcceptUserCrossBorderCdtNotOpened The operation failed because the CrossBorderCdt service of accept user is not opened. The operation failed because the cross-border service of CDT is not activated for the peer.
400 IncorrectBusinessStatus.AcceptUserVpcPeer The business status of %s [%s] is incorrect. The peer VPC is in an invalid business state.
400 OperationFailed.ViolativeVpcPeer The creation operation fails because it is not allowed to create a vpc peer instance between the originating region and the receiving region. the creation operation fails because it is not allowed to create a vpc peer instance between the originating region and the receiving region.
400 QuotaExceeded.CrossRegionVpcPeerCountPerVpc The quota of %s is exceeded, usage %s/%s. The number of cross-region VpcPeer in the specified VPC exceeds the limit
400 QuotaExceeded.IntraRegionVpcPeerCountPerVpc The quota of %s is exceeded, usage %s/%s. The number of VpcPeer in the same region in the specified VPC exceeds the limit
400 OperationDenied.OperateShareResource The operation is not allowed because of operating shared resource. Operating on shared resources causes the operation to fail
400 IncorrectBusinessStatus.AcceptVpcPeer The business status of peer account is incorrect. The business status of the peer VpcPeer in an invalid state.
400 OperationFailed.InterRegionLinkTypeNotSupported The same region not supported link type feature. Link type characteristics are not supported in the same region.
400 OperationFailed.RegionIdNotSupportLinkType The feature link type is not supported in the region. The gold, silver and copper settings for this feature are not supported in the region.
400 OperationFailed.SpecificLinkTypeNotSupported The operation failed because the special link type of user is not opened. The account does not support special link types.
400 OperationFailed.CrossBusinessNotAllowed Operation failed because receiver and accepter belong to different business site. The initiator and receiver belong to different sites and cannot create VpcPeer
400 OperationFailed.ChargeTypeNotSupported Operation failed because the CDT charge type of receiver or accepter does not support the Underlay link type. The operation failed because the CDT charging type of the initiator or the recipient does not support the Underlay link type.

See Error Codes for a complete list.

Release notes

See Release Notes for a complete list.