全部产品
Search
文档中心

云企业网:CreateTransitRouterVpcAttachment - 在企业版转发路由器下创建专有网络VPC连接

更新时间:Jul 14, 2025

调用CreateTransitRouterVpcAttachment接口将要互通的专有网络VPC(Virtual Private Cloud)实例连接至转发路由器实例。连接后,转发路由器实例可以帮助您实现私网互通。

接口说明

  • 您可以通过以下两种方式在企业版转发路由器下创建 VPC 连接:

    • 如果您已经在目标地域创建了企业版转发路由器实例,您可以通过指定 VpcIdZoneMappings.N.VSwitchIdZoneMappings.N.ZoneIdTransitRouterIdRegionId 创建 VPC 连接。

    • 如果您在目标地域没有企业版转发路由器实例,您可以通过指定 VpcIdZoneMappings.N.VSwitchIdZoneMappings.N.ZoneIdCenIdRegionId 创建 VPC 连接。创建 VPC 连接时系统为您自动创建企业版转发路由器实例。

  • CreateTransitRouterVpcAttachment 接口属于异步接口,即系统会先返回一个 VPC 连接 ID,但该 VPC 连接并未创建完成,系统后台的创建任务仍在进行。您可以调用 ListTransitRouterVpcAttachments 接口查询 VPC 连接的状态。

    • 当 VPC 连接处于 Attaching 状态时,表示 VPC 连接正在创建中,在该状态下,您只能对 VPC 连接执行查询操作,不能执行其他操作。

    • 当 VPC 连接处于 Attached 状态时,表示 VPC 连接创建完成。

  • 创建 VPC 连接后,VPC 连接默认不与任何转发路由器路由表建立路由学习关系和关联转发关系。

前提条件

在调用本接口创建 VPC 连接前,请确保满足以下条件:

  • VPC 实例在企业版转发路由器支持的可用区拥有至少一个交换机实例,且该交换机实例拥有至少一个空闲的 IP 地址。关于企业版转发路由器支持的地域和可用区信息,请参见企业版转发路由器支持的地域和可用区

  • 如果您要连接跨账号的网络实例,请先获得跨账号网络实例授权。具体操作,请参见跨账号网络实例授权

  • VPC 连接创建后会产生费用,请确保您已经了解相关计费规则。更多信息,请参见计费说明

调试

您可以在OpenAPI Explorer中直接运行该接口,免去您计算签名的困扰。运行成功后,OpenAPI Explorer可以自动生成SDK代码示例。

调试

授权信息

下表是API对应的授权信息,可以在RAM权限策略语句的Action元素中使用,用来给RAM用户或RAM角色授予调用此API的权限。具体说明如下:

  • 操作:是指具体的权限点。

  • 访问级别:是指每个操作的访问级别,取值为写入(Write)、读取(Read)或列出(List)。

  • 资源类型:是指操作中支持授权的资源类型。具体说明如下:

    • 对于必选的资源类型,用前面加 * 表示。

    • 对于不支持资源级授权的操作,用全部资源表示。

  • 条件关键字:是指云产品自身定义的条件关键字。

  • 关联操作:是指成功执行操作所需要的其他权限。操作者必须同时具备关联操作的权限,操作才能成功。

操作

访问级别

资源类型

条件关键字

关联操作

cen:CreateTransitRouterVpcAttachment

create

CenInstance

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

TransitRouter

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

请求参数

名称

类型

必填

描述

示例值

ClientToken

string

客户端 Token,用于保证请求的幂等性。

从您的客户端生成一个参数值,确保不同请求间该参数值唯一。ClientToken 只支持 ASCII 字符。

说明

若您未指定,则系统自动使用 API 请求的 RequestId 作为 ClientToken 标识。每次 API 请求的 RequestId 不一样。

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

CenId

string

云企业网实例 ID。

cen-j3jzhw1zpau2km****

TransitRouterId

string

企业版转发路由器实例 ID。

tr-bp1su1ytdxtataupl****

RegionId

string

VPC 实例所属地域 ID。

您可以通过调用 DescribeChildInstanceRegions 接口获取地域 ID。

cn-hangzhou

TransitRouterAttachmentName

string

VPC 连接的名称。

名称可以为空或长度为 1~128 个字符,不能以 http://或 https://开头。

testname

TransitRouterAttachmentDescription

string

VPC 连接的描述信息。

描述可以为空或长度为 1~256 个字符,不能以 http://或 https://开头。

testname

VpcId

string

VPC 实例 ID。

vpc-bp1kbjcre9vtsebo1****

VpcOwnerId

integer

VPC 实例所属阿里云账号(主账号)ID。默认值为当前登录的阿里云账号 ID。

说明

如果您要加载跨账号的网络实例,本参数必填。

1250123456123456

ChargeType

string

付费方式。默认值:POSTPAY,表示按量付费。

POSTPAY

DryRun

boolean

是否对此次请求执行预检,包括权限、实例状态校验等。取值:

  • false(默认值):发送正常请求,通过检查后直接创建 VPC 连接。

  • true:发送检查请求,只进行校验,不会创建 VPC 连接。检查项包括是否填写了必需参数、请求格式等。如果检查不通过,则返回对应错误。如果检查通过,则返回错误码DryRunOperation

false

ZoneMappings

array

请在企业版转发路由器的可用区中选择一个交换机实例。

一次最多支持添加 10 组信息。

object

企业版转发路由器支持的可用区及其对应的交换机实例的信息。

VSwitchId

string

在企业版转发路由器支持的可用区中选择一个交换机实例。

一次最多支持为 10 个可用区选择交换机实例。

vsw-bp1a214sbus8z3b54****

ZoneId

string

企业版转发路由器支持的可用区的 ID。

您可以通过 DescribeZones 接口查询可用区的 ID。

一次最多支持选择 10 个可用区。

cn-hangzhou-h

AutoPublishRouteEnabled

boolean

是否使企业版转发路由器自动发布路由到 VPC 实例。

  • false(默认值):否。

  • true:是。

true

TransitRouterVPCAttachmentOptions

object

VPC 连接的功能属性列表。

string

VPC 连接的功能属性。

ipv6Support:是否开启 IPv6 功能。

  • enable:开启 IPv6 功能。

  • disable(默认值):关闭 IPv6 功能。

说明

为 VPC 连接开启 IPv6 功能前,请确保 VPC 实例及其关联的交换机实例已经开启 IPv6 功能。具体操作,请参见 AllocateVpcIpv6CidrCreateVSwitchCidrReservation

Tag

array

标签列表。

一次最多支持输入 20 个标签信息。

object

标签。

Key

string

资源的标签键。

一旦传入该值,则不允许为空字符串。最多支持 64 个字符,不能以aliyun或者acs:开头,不能包含http://或者https://

一次最多支持输入 20 个标签的标签键。

tagtest

Value

string

资源的标签值。

标签值可以为空或输入不超过 128 个字符的字符串,不能以aliyun或者acs:开头,不能包含http://或者https://

每一个标签键对应一个标签值,一次最多支持输入 20 个标签键对应的标签值。

tagtest

返回参数

名称

类型

描述

示例值

object

返回结果。

TransitRouterAttachmentId

string

VPC 连接 ID。

tr-attach-ia340z7xis7t5s****

RequestId

string

请求 ID。

C087A369-82B9-43EF-91F4-4B63A9C6E6B6

示例

正常返回示例

JSON格式

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

错误码

HTTP status code

错误码

错误信息

描述

400 OperationUnsupported.TransitRouterRegionId The specified TransitRouterRegion 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. 您没有权限创建服务关联角色,角色名:AliyunServiceRoleForCEN,服务名:cen.aliyuncs.com。请确保已授予当前用户ram:CreateServiceLinkedRole权限。
400 IllegalParam.RegionId The Specified Parameter RegionId is illegal 参数中指定的Region不合法。
400 MissingParam.CenIdOrRegionId Either CenId or RegionId must be specified. CenId或者RegionId是必选参数。
400 IllegalParam.ZoneId The specified ZoneId is illegal. 传入的可用区非法
400 IllegalParam.ChargeType The specified ChargeType is illegal. 付费类型非法
400 InvalidTransitRouterId.NotFound The specified TransitRouterId is not found. 指定的转发路由器不存在
400 IncorrectStatus.VpcResource The resource is not in a valid state for the attachment operation. 当前VPC资源不处于稳态,无法进行该操作,请等待与当前VPC相关操作结束后重试。
400 IncorrectStatus.Vpc The resource is not in a valid state for the attachment operation. 当前VPC的状态不支持该操作,请稍后重试。
400 IncorrectStatus.VpcOrVswitch The Vpc Or Vswith is not in a valid state for the attachment operation. 当前vpc或vswitch的状态不支持该操作,请稍后重试。
400 OperationNotSupport.VpcAutoRoutesPublish Auto publish vpc routes is not supported in this region. 当前地域暂不支持vpc路由自动发布。
400 InvalidOperation.VpnAssociated The operation is not supported because the VPC is associated with VPN. 当前VPC与VPN绑定,无法打开路由自动同步功能。
400 Forbbiden.TransitRouterServiceNotOpen The user has not open transit router service. 转发路由器服务未打开,请打开后重试。
400 IllegalParam.ZoneMappings The Specified Parameter ZoneMappings is illegal 参数中指定的ZoneMappings不合法。
400 OperationUnsupported.TransitRouterType The specified TransitRouterType does not support the operation. 当前TransitRouter类型不支持该操作。
400 InvalidCenId.NotFound CenId is not found. CEN实例不存在。
400 IllegalParam.VSwitchId VSwitchId is illegal. 参数中指定的VSwitchId不合法。
400 IncorrectStatus.TransitRouterInstance The status of TransitRouter is incorrect. 转发路由器状态不正确。
400 OperationUnsupported.CenFullLevel CEN full level does not support TransitRouter Full类型CEN不支持创建企业版转发路由器。
400 IllegalParam.ServiceMode ServiceMode is illegal. ServiceMode不合法。
400 QuotaFull.ChildInstanceRelatedCen The childinstance has exceed the quota of the times that a childinstance can be attached as an attachment. 该实例绑定CEN数量已达到上限,无法加载。
400 OperationUnsupported.CloudBoxVswNotSupport Cloud Box vsw does not support. 云盒的vsw不允许加载。
400 IncorrectStatus.TransitRouter The status of TransitRouter is incorrect. 当前TransitRouter的状态不支持该操作,请稍后重试。
400 Duplicated.ZoneMapping The parameter ZoneMapping is duplicated. ZoneMapping中存在重复的条目。
400 QuotaExceeded.CenQuotaVpcAttachPerTransitRouter The maximum number of VPC attachment per Transit Router is exceeded. 每个转发路由器支持连接的专有网络VPC个数超限。
400 IncorrectStatus.VpcRouteTable The VPC route table is not in a desired state. 该操作相关的VPC路由表不处于稳态,无法操作,请稍后重试。
400 InvalidStatus.VpcAttachedFullModeCen The VPC has been attached to another CEN instance whose protection level is FULL. 参数中指定的vpc加载到另一个protection level为FULL的cen中,无法再加载到其他cen中。
400 Forbbiden.AttachChildInstanceAcrossBid VPCs that belong to another BID cannot be associated. You need to apply for cross-BID attaching. 不允许绑定不同bid账号下的VPC。
400 InvalidOperation.VpcAutoRoutesPublishInOtherCEN The specified VPC already has its routes synchronized with another CEN instance. 当前VPC已经在其他CEN中开启了路由自动同步,无法支持该操作。
400 QuotaExceeded.VpcAutoRoutesPublishPerTransitRouter The number of VPCs that have route synchronization enabled has reached the upper limit. 开启路由自动同步的VPC数量已达到上限。
400 InsufficientIpAddr.vsw Insufficient available IP addresses in the vSwitch. 虚拟交换机中的可用IP数目不足
400 Forbidden.ResourceOwnerTransitRouterServiceNotOpen The resource owner user has not opened transit router service. 资源所属账号转发路由器服务未开通,请通知对方开通后重试。
400 IllegalParam.TransitRouterRegionId TransitRouterRegionId is illegal. TransitRouterRegionId不合法。
400 InvalidTransitRouterMode.NeedUpgrade TransitRouter need to upgrade. 当前转发路由器模式不支持。
400 IllegalParam.Ipv6Support Ipv6Support is illegal. Valid Values are [enable, disable]. 请求参数Ipv6Support值非法,有效值为enable或disable。
400 OperationFailed.VSwitchNotFound The specified vswitch not found. 指定的VSwitchId不存在,请确认该VSwitch状态是否可用或指定其他可用的VSwitch。
400 OperationFailed.VSwitchIpv6CidrNotAllocated The specified vswitch does not have IPv6 address allocated. 指定的VSwitch未开通Ipv6,请开通Ipv6后再进行该操作。
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. 资源所属账号的转发路由器服务已欠费停服,请通知对方续费后重试。
400 Forbidden.TransitRouterServiceExpired The transit router service is out of service. 转发路由器服务已欠费停服,请续费后重试。
400 InvalidParameter Invalid parameter. 参数不合法。
400 Unauthorized The AccessKeyId is unauthorized. 账号无权限操作。
400 InvalidParameter.ResourceType The specified parameter ResourceType is invalid.
404 InvalidVSwitchId.NotFound The specified VSwitchId is not found. 指定的VSwitchId不存在。
409 InvalidOperation.CenInstanceStatus The CEN instance is not in a valid state for the operation. cen当前状态不支持该操作,请稍后重试。
409 IncorrectStatus.VpcSwitch The resource is not in a valid state for the attachment operation.

访问错误中心查看更多错误码。

变更历史

更多信息,参考变更详情