Creates a virtual private cloud (VPC) connection from an Enterprise Edition transit router.

Prerequisites

Before you call this operation, make sure that the following requirements are met:

  • At least two vSwitches that belong to different zones are deployed in the VPC. For more information about the regions and zones that support Enterprise Edition transit routers, see Transit routers.
  • To connect to a network instance that is created by another account, you must first acquire the permissions from the account to which the network instance belongs. For more information, see Acquire permissions to connect to a network instance that belongs to another account.
  • Make sure that you understand the billing of VPC connections before you create a VPC connection. For more information, see Transit router billing.

Description

You can use the following methods to create a VPC connection from an Enterprise Edition transit router:

  • If an Enterprise Edition transit router is already created in the region where you want to create a VPC connection, specify VpcId, ZoneMappings.N.VSwitchId, ZoneMappings.N.ZoneId, and TransitRouterId.
  • If no Enterprise Edition transit router is created in the region where you want to create a VPC connection, specify VpcId, ZoneMappings.N.VSwitchId, ZoneMappings.N.ZoneId, CenId, and RegionId. When you create a VPC connection, the system automatically creates an Enterprise Edition transit router in the specified region.

Debugging

OpenAPI Explorer automatically calculates the signature value. For your convenience, we recommend that you call this operation in OpenAPI Explorer. OpenAPI Explorer dynamically generates the sample code of the operation for different SDKs.

Request parameters

Parameter Type Required Example Description
Action String No CreateTransitRouterVpcAttachment

The operation that you want to perform. Set the value to CreateTransitRouterVpcAttachment.

VpcId String Yes vpc-bp1kbjcre9vtsebo1****

The ID of the VPC.

ZoneMappings.N.VSwitchId String Yes vsw-bp1a214sbus8z3b54****

Specify a vSwitch that is deployed in the primary zone of the Enterprise Edition transit router. Specify another vSwitch that is deployed in the secondary zone of the Enterprise Edition transit router. Maximum value of N: 2.

ZoneMappings.N.ZoneId String Yes cn-hangzhou-h

The primary and secondary zones of the Enterprise Edition transit router. Maximum value of N: 2.

You can call the DescribeZones operation to query zone IDs.

ClientToken String No 02fb3da4-130e-11e9-8e44-001****

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

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

CenId String No cen-j3jzhw1zpau2km****

The ID of the Cloud Enterprise Network (CEN) instance.

TransitRouterId String No tr-bp1su1ytdxtataupl****

The ID of the Enterprise Edition transit router.

RegionId String No cn-shanghai

The region ID of the VPC.

TransitRouterAttachmentName String No testname

The name of the VPC connection.

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

TransitRouterAttachmentDescription String No testname

The description of the VPC 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://.

VpcOwnerId Long No 1688111111111111

The UID of the account to which the VPC belongs. The default value is the UID of the current account.

ChargeType String No POSTPAY

The billing method. Default value: POSTPAY (pay-as-you-go).

DryRun Boolean No false

Specifies whether to only precheck the request. Check items include permissions and the status of the specified instances. Valid values:

  • false (default): sends a normal request. If the request passes the precheck, the VPC connection is created.
  • true: sends a request for precheck only. No VPC connection is created after the request passes the precheck. If you select this option, the system checks whether the required parameters are set, and whether the request syntax is valid. If the request fails to pass the precheck, the system returns an error. If the request passes the precheck, the system returns the ID of the request.

Response parameters

Parameter Type Example Description
RequestId String C087A369-82B9-43EF-91F4-4B63A9C6E6B6

The ID of the request.

TransitRouterAttachmentId String tr-attach-ia340z7xis7t5s****

The ID of the VPC connection.

Examples

Sample requests

http(s)://[Endpoint]/?Action=CreateTransitRouterVpcAttachment
&VpcId=vpc-bp1kbjcre9vtsebo1****
&ZoneMappings.1.VSwitchId=vsw-bp1a214sbus8z3b54****
&ZoneMappings.1.ZoneId=cn-hangzhou-h
&<Common request parameters>

Sample success responses

XML format

<CreateTransitRouterVpcAttachmentResponse> 
  <TransitRouterAttachmentId>tr-attach-ia340z7xis7t5s****</TransitRouterAttachmentId>
  <RequestId>C087A369-82B9-43EF-91F4-4B63A9C6E6B6</RequestId>
</CreateTransitRouterVpcAttachmentResponse>

JSON format

{
  "TransitRouterAttachmentId": "tr-attach-ia340z7xis7t5s****",
  "RequestId": "C087A369-82B9-43EF-91F4-4B63A9C6E6B6"
}

Error codes

HttpCode Error code Error message Description
400 OperationUnsupported.TransitRouterRegionId The specified TransitRouterRegion does not support the operation. The error message returned because the specified region does not support the operation.
400 NoPermission.AliyunServiceRoleForCEN You are not authorized to create the service linked role. Role Name: AliyunServiceRoleForCEN. Service Name: cen.aliyuncs.com. Make sure that the user has been granted the ram:CreateServiceLinkedRole permission. The error message returned because you are unauthorized to create the service-linked role AliyunServiceRoleForCEN for the service ServiceName:cen.aliyuncs.com. You must acquire the ram:CreateServiceLinkedRole permission before you can perform the operation.
400 MissingParam.CenIdOrRegionId Either CenId or RegionId must be specified. The error message returned because CenId or RegionId is not specified.

For a list of error codes, visit the API Error Center.