All Products
Search
Document Center

Cloud Enterprise Network:CreateTransitRouterVpnAttachment

Last Updated:Oct 29, 2025

A transit router supports IPsec-VPN connections, allowing a data center to connect to the transit router and communicate with other networks. You can call the CreateTransitRouterVpnAttachment operation to create a VPN connection.

Operation description

  • After you create a VPN connection, the connection does not learn routes from or associate with any route table of the transit router by default.

  • When you call the CreateTransitRouterVpnAttachment operation, you do not need to specify TransitRouterId if you specify CenId and RegionId. You do not need to specify CenId if you specify TransitRouterId and RegionId.

Prerequisites

  • Before you create a VPN connection, make sure that you have created an IPsec-VPN connection in the same region as the transit router instance and that the IPsec-VPN connection is not attached to any resource. For more information, see CreateVpnAttachment.

  • If the transit router instance needs to connect to a cross-account IPsec-VPN connection, make sure that the transit router instance is granted the required permissions on the IPsec-VPN connection. For more information, see GrantInstanceToTransitRouter.

  • Before you create a VPN connection, make sure that you have configured a CIDR block for the transit router. For more information, see CreateTransitRouterCidr.

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

cen:CreateTransitRouterVpnAttachment

create

CenInstance

acs:cen:*:{#accountId}:ceninstance/{#ceninstanceId}

TransitRouter

acs:cen:*:{#accountId}:centransitrouter/{#TransitRouterId}

None None

Request parameters

Parameter

Type

Required

Description

Example

ClientToken

string

No

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

Generate a unique token on your client. The token can contain only ASCII characters.

Note

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

123e4567-e89b-12d3-a456-42665544****

DryRun

boolean

No

Specifies whether to perform a dry run. Valid values:

  • true: performs a dry run but does not create the VPN connection. The system checks the request for required parameters, format, and service limits. If the request fails the check, an error message is returned. If the request passes the check, the DryRunOperation error code is returned.

  • false (default): performs a dry run and creates the VPN connection if the request passes the check.

false

CenId

string

No

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

cen-rsgxs8ng2awen2****

TransitRouterId

string

No

The ID of the transit router instance.

tr-p0wm740vjnbaprv0m****

RegionId

string

No

The ID of the region where the transit router instance is deployed.

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

cn-hangzhou

TransitRouterAttachmentName

string

No

The name of the VPN connection.

The name can be empty or 1 to 128 characters in length, and cannot start with `http://` or `https://`.

nametest

TransitRouterAttachmentDescription

string

No

The description of the VPN connection.

The description can be empty or 1 to 256 characters in length, and cannot start with `http://` or `https://`.

desctest

VpnId

string

Yes

The ID of the IPsec-VPN connection.

vco-p0w042cqwvlhl4zyw****

VpnOwnerId

integer

No

The ID of the Alibaba Cloud account to which the IPsec-VPN connection belongs.

  • If you do not specify this parameter, the ID of the current Alibaba Cloud account is used.

  • This parameter is required if you want to connect to a cross-account IPsec-VPN connection.

1210123456123456

AutoPublishRouteEnabled

boolean

No

Specifies whether to enable the transit router to automatically publish routes to the IPsec-VPN connection. Valid values:

  • true (default): enabled.

  • false: disabled.

true

ChargeType

string

No

The billing method.

The value is set to POSTPAY (default), which specifies the pay-as-you-go billing method.

POSTPAY

Zone

array<object>

No

The ID of the zone in the current region.

The system creates resources in the specified zone.

Note

Do not specify this parameter if the attached IPsec-VPN connection is in dual-tunnel mode.

object

No

The zone ID.

ZoneId

string

No

The zone ID.

You can call the ListTransitRouterAvailableResource operation to query available zones.

cn-hangzhou-h

Tag

array<object>

No

The tags.

You can specify up to 20 tags.

object

No

The tag.

Key

string

No

The tag key.

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

You can specify up to 20 tag keys.

TagKey

Value

string

No

The tag value.

The tag value can be an empty string or a string of up to 128 characters. It cannot start with aliyun or acs: and cannot contain http:// or https://.

You can specify up to 20 tag values.

TagValue

Response elements

Element

Type

Description

Example

object

The response.

TransitRouterAttachmentId

string

The ID of the VPN connection.

tr-attach-y5dup2qwfyh9lu****

RequestId

string

The request ID.

8B5DD40A-3A29-5AC0-B8DA-05FD10D5C893

Examples

Success response

JSON format

{
  "TransitRouterAttachmentId": "tr-attach-y5dup2qwfyh9lu****",
  "RequestId": "8B5DD40A-3A29-5AC0-B8DA-05FD10D5C893"
}

Error codes

HTTP status code

Error code

Error message

Description

400 NoPermission.AliyunServiceRolePolicyForCEN You are not authorized to create the service linked role. Role Name: AliyunServiceRolePolicyForCEN. Service Name: cen.aliyuncs.com. Make sure that the user has been granted the ram:CreateServiceLinkedRole permission. The error message returned because you do not have the permissions to create the service-linked role whose role name is AliyunServiceRolePolicyForCEN and service name is cen.aliyuncs.com. You must acquire the ram:CreateServiceLinkedRole permission before you can create the service-linked role.
400 OperationUnsupported.TransitRouterRegionId The specified TransitRouterRegion does not support the operation.
400 InvalidCenId.NotFound CenId is not found. The error message returned because the specified CEN instance does not exist.
400 InvalidStatus.ResourceStatus The resource is not in a valid state for the attachment operation. The error message returned because the status of the specified resource does not support this operation. Try again later.
400 InvalidTransitRouterId.NotFound TransitRouterId is not found. The error message returned because the ID of the transit router does not exist.
400 Forbbiden.TransitRouterServiceNotOpen The user has not open transit router service. The error message returned because the transit router is disabled. Enable the transit router and try again.
400 InvalidTransitRouterMode.NeedUpgrade TransitRouter need to upgrade. The error message returned because the specified transit router mode is not supported.
400 InvalidAvailable.NoResource No resource in the available zone. The error message returned because resources are insufficient in the specified region.
400 OperationUnsupported.VpnAttachment The specified region does not support the operation. The error message returned because this operation is not supported in the specified region.
400 OperationUnsupported.TransitRouterType The specified TransitRouterType does not support the operation. The error message returned because this operation is not supported by the specified type of transit router.
400 OperationFailed.AllocateCidrFailed Operation failed because vpn allocate cidr failed. The error message returned because the VPN failed to apply for a CIDR block.
400 OperationUnsupported.ZoneId The specified ZoneId does not support the operation.
400 MissingParam.CenIdOrRegionId Either CenId or RegionId must be specified. The error message returned because the CenId or RegionId parameter is not set.
400 IllegalParam.RegionId RegionId is illegal. The error message returned because the specified region is invalid.
400 OperationUnsupported.CenFullLevel CEN full level does not support TransitRouter The error message returned because CEN instances of the Full type do not support Enterprise Edition transit routers.
400 InvalidOperation.CenInstanceStatus The CEN instance is not in a valid state for the operation.
400 IllegalParam.ZoneMappings The Specified Parameter ZoneMappings is illegal The error message returned because the specified zone mappings (ZoneMappings) is invalid.
400 IncorrectStatus.TransitRouter The status of TransitRouter is incorrect. The error message returned because the status of the transit router does not support this operation. Try again later.
400 InvalidOperation.VpnNetworkTypeInvalid The network type of child-instance is invalid. The error message returned because the network type specified for the instance is invalid.
400 QuotaExceeded.CenQuotaVpnAttachPerTransitRouter The maximum number of VPN attachment per Transit Router is exceeded. The error message returned because specified number of VPN attachments to the transit router exceeds the upper limit. You can submit a ticket to request a quota increase.
400 QuotaFull.ChildInstanceRelatedCen The childinstance has exceed the quota of the times that a childinstance can be attached as an attachment. The error message returned because the number of CEN instances to which the instance is attached has reached the upper limit. You cannot attach the instance to more CEN instances.
400 Forbidden.ResourceOwnerTransitRouterServiceNotOpen The resource owner user has not opened transit router service. The transit router service for the resource owner's account is not currently opened. Please inform them to open the transit router service and then try again.
400 OperationUnsupported.VcoTunnelNotMatchZoneParam The tunnel type of the entered Vco does not match the Zone parameter. The tunnel type of the entered Vco does not match the Zone parameter.
400 Forbidden.ResourceOwnerTransitRouterServiceExpired The transit router service of the account to which the resource belongs has been suspended due to arrears. Please notify the other party to renew the service and try again. The transit router service of the account to which the resource belongs has been suspended. Please notify the other party to renew the service and try again.
400 Forbidden.TransitRouterServiceExpired The transit router service is out of service. The transit router service has been suspended due for payment. Please renew the service and try again.
400 InvalidParameter Invalid parameter. The error message returned because the parameter is set to an invalid value.
400 Unauthorized The AccessKeyId is unauthorized. The error message returned because you do not have the permissions to perform this operation.
400 IllegalParam.TransitRouterRegionId TransitRouterRegionId is illegal. The error message returned because the specified transit router region ID (TransitRouterRegionId) is invalid.
400 InvalidVpnId.NotFound The specified vpn connection instance id does not exist. The specified vpn connection instance id does not exist.
400 InvalidParameter.ResourceType The specified parameter ResourceType is invalid.
400 InvalidParameter.VpnId The specified parameter VpnId is invalid.
400 IllegalParam.ChargeType The specified ChargeType is illegal. The error message returned because the specified billing method is invalid.

See Error Codes for a complete list.

Release notes

See Release Notes for a complete list.