CreateVpcPeerConnection

Updated at: 2025-02-21 07:43

Creates 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 a request is sent, the system returns an instance ID and runs the task in the background. You can call GetVpcPeerConnectionAttribute to query the status of the task.

    • 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, it is a cross-account connection. The connection needs to be accepted on the accepter side.
  • You cannot repeatedly call CreateVpcPeerConnection within the specified period of time.

When you create a VPC peering connection, the system automatically activates Cloud Data Transfer (CDT) for you.

Debugging

You can run this interface directly in OpenAPI Explorer, saving you the trouble of calculating signatures. After running successfully, OpenAPI Explorer can automatically generate SDK code samples.

Authorization information

The following table shows the authorization information corresponding to the API. The authorization information can be used in the Action policy element to grant a RAM user or RAM role the permissions to call this API operation. Description:

  • Operation: the value that you can use in the Action element to specify the operation on a resource.
  • Access level: the access level of each operation. The levels are read, write, and list.
  • Resource type: the type of the resource on which you can authorize the RAM user or the RAM role to perform the operation. Take note of the following items:
    • For mandatory resource types, indicate with a prefix of * .
    • If the permissions cannot be granted at the resource level, All Resources is used in the Resource type column of the operation.
  • Condition Key: the condition key that is defined by the cloud service.
  • Associated operation: other operations that the RAM user or the RAM role must have permissions to perform to complete the operation. To complete the operation, the RAM user or the RAM role must have the permissions to perform the associated operations.
OperationAccess levelResource typeCondition keyAssociated operation
OperationAccess levelResource typeCondition keyAssociated operation
vpc:CreateVpcPeerConnectioncreate
*All Resources
*
    none
none

Request parameters

ParameterTypeRequiredDescriptionExample
ParameterTypeRequiredDescriptionExample
RegionIdstringYes

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

You can call the DescribeRegions operation to query the most recent region list.

cn-hangzhou
VpcIdstringYes

The ID of the requester VPC.

vpc-bp1gsk7h12ew7oegk****
AcceptingAliUidlongYes

The ID of the Alibaba Cloud account to which the accepter VPC belongs.

  • To create a VPC peering connection within your Alibaba Cloud account, enter the ID of your Alibaba Cloud account.
  • To create a VPC peering connection between your Alibaba Cloud account and another Alibaba Cloud account, enter the ID of the peer Alibaba Cloud account.
Note
If the accepter is a RAM user, set AcceptingAliUid to the ID of the Alibaba Cloud account that created the RAM user.
1210123456123456
AcceptingRegionIdstringYes

The region ID of the accepter VPC of the VPC peering connection that you want to create.

  • To create an intra-region VPC peering connection, enter a region ID that is the same as that of the requester VPC.
  • To create an inter-region VPC peering connection, enter a region ID that is different from that of the requester VPC.
cn-hangzhou
AcceptingVpcIdstringYes

The ID of the accepter VPC.

vpc-bp1vzjkp2q1xgnind****
NamestringNo

The name of the VPC peering connection.

The name must be 2 to 128 characters in length, and can contain digits, underscores (_), and hyphens (-). It must start with a letter.

vpcpeer
DescriptionstringNo

The description of the VPC peering connection.

The description must be 2 to 256 characters in length. The description must start with a letter but cannot start with http:// or https://.

description
DryRunbooleanNo

Specifies whether to perform only a dry run, without performing the actual request. Valid values:

  • true: performs only a dry run. The system checks the request for potential issues, including missing parameter values, incorrect request syntax, and service limits. If the request fails the dry run, an error code is returned. If the request passes the dry run, the DryRunOperation error code is returned.
  • false (default): performs a dry run and performs the actual request. If the request passes the dry run, a 2xx HTTP status code is returned and the operation is performed.
false
ClientTokenstringNo

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 request ID as the client token. The request ID may be different for each request.
02fb3da4-130e-11e9-8e44-001****
ResourceGroupIdstringNo

The ID of the resource group.

For more information about resource groups, see Resource groups.

rg-acfmxazb4ph6aiy****
BandwidthintegerNo

The bandwidth of the VPC peering connection. Unit: Mbit/s. The value must be an integer greater than 0. Before you specify this parameter, make sure that you create an inter-region VPC peering connection.

100
LinkTypestringNo

The link type of the VPC peering connection that you want to create. Valid values:

  • Platinum.

  • Gold: default value.

Note
  • If you need to specify this parameter, ensure that the VPC peering connection is an inter-region connection.
  • Gold
    Tagarray<object>No

    The tags.

    objectNo

    The tags.

    KeystringNo

    The tag key. You must specify at least one tag key and at most 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 acs: or aliyun and cannot contain http:// or https://.

    FinanceDept
    ValuestringNo

    The tag value. You must specify at least one tag value and can specify at most 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 parameters

    ParameterTypeDescriptionExample
    ParameterTypeDescriptionExample
    object

    The request ID.

    RequestIdstring

    The request ID.

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

    The ID of the instance on which the VPC peering connection is created.

    pcc-lnk0m24khwvtkm****

    Examples

    Sample success responses

    JSONformat

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

    Error codes

    HTTP status codeError codeError messageDescription
    HTTP status codeError codeError messageDescription
    400OperationFailed.CdtNotOpenedThe operation failed because the Cdt service is not opened.The operation failed because CDT is not activated.
    400OperationFailed.CrossBorderCdtNotOpenedThe operation failed because the CrossBorderCdt service is not opened.-
    400IncorrectStatus.VpcThe status of %s [%s] is incorrect.The status of the initiator VPC instance is incorrect.
    400IncorrectStatus.AcceptingVpcThe status of %s [%s] is incorrect.The receiving VPC status is incorrect.
    400ResourceAlreadyExist.RouterInterfaceThe specified resource of %s already exists.The specified router interface already exists.
    400ResourceAlreadyExist.VpcPeerThe specified resource of %s already exists.The specified VPC peering connection already exists.
    400OperationDenied.CloudBoxExistsInVpcThe 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.
    400OperationDenied.CloudBoxExistsInAcceptingVpcThe 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.
    400QuotaExceeded.VpcPeerCountPerVpcThe quota of %s is exceeded, usage %s/%s.The number of VPC peering connections to the VPC has reached the upper limit.
    400UnsupportedRegionThe feature of %s is not supported in the region of %s.VPC peering connections are not supported in this region.
    400QuotaExceeded.VpcPeerCountPerUserPerRegionThe quota of %s is exceeded, usage %s/%s.The number of VpcPeer instances in a region exceeds the threshold.
    400IncorrectBusinessStatus.VpcPeerThe business status of %s [%s] is incorrect.The current instance status is abnormal and the current operation is not allowed.
    400OperationFailed.NotExist.ResourceGroupThe operation failed because the resource group does not exist.The operation failed because the resource group does not exist.
    400OperationFailed.AcceptUserCdtNotOpenedThe operation failed because the Cdt service of accept user is not opened.The operation failed because CDT is not activated for the peer.
    400OperationFailed.AcceptUserCrossBorderCdtNotOpenedThe 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.
    400IncorrectBusinessStatus.AcceptUserVpcPeerThe business status of %s [%s] is incorrect.The peer VPC is in an invalid business state.
    400OperationFailed.ViolativeVpcPeerThe 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.
    400OperationFailed.ViolativeVpcPeerThe operation failed because it is out of compliance to create a vpc peer between originating region and accepting region.the creation operation fails because it is not allowed to create a vpc peer instance between the originating region and the receiving region.
    400QuotaExceeded.CrossRegionVpcPeerCountPerVpcThe quota of %s is exceeded, usage %s/%s.The number of cross-region VpcPeer in the specified VPC exceeds the limit
    400QuotaExceeded.IntraRegionVpcPeerCountPerVpcThe quota of %s is exceeded, usage %s/%s.The number of VpcPeer in the same region in the specified VPC exceeds the limit
    400OperationDenied.OperateShareResourceThe operation is not allowed because of operating shared resource.Operating on shared resources causes the operation to fail
    400IncorrectBusinessStatus.AcceptVpcPeerThe business status of peer account is incorrect.The business status of the peer VpcPeer in an invalid state.
    400OperationFailed.InterRegionLinkTypeNotSupportedThe same region not supported link type feature.Link type characteristics are not supported in the same region.
    400OperationFailed.RegionIdNotSupportLinkTypeThe feature link type is not supported in the region.The gold, silver and copper settings for this feature are not supported in the region.
    400OperationFailed.SpecificLinkTypeNotSupportedThe operation failed because the special link type of user is not opened.The account does not support special link types.

    For a list of error codes, visit the Service error codes.

    Change history

    Change timeSummary of changesOperation
    Change timeSummary of changesOperation
    2025-02-20The Error code has changed. The request parameters of the API has changedView Change Details
    2024-12-04The Error code has changed. The request parameters of the API has changedView Change Details
    2024-08-12The Error code has changedView Change Details
    2024-07-02The Error code has changedView Change Details
    2024-06-05The Error code has changedView Change Details
    2024-03-13The Error code has changedView Change Details
    2024-02-28The Error code has changedView Change Details
    2023-11-20API Description Update. The Error code has changed. The request parameters of the API has changedView Change Details
    2023-05-30The Error code has changed. The request parameters of the API has changedView Change Details
    • On this page (1)
    • Operation description
    • Debugging
    • Authorization information
    • Request parameters
    • Response parameters
    • Examples
    • Error codes
    • Change history
    Feedback