全部產品
Search
文件中心

Virtual Private Cloud:CreateVpcPeerConnection - 建立VPC對等串連

更新時間:Aug 14, 2025

調用CreateVpcPeerConnection介面建立VPC對等串連。

介面說明

建立 VPC 對等串連前,您需要完成以下事項:

  • CreateVpcPeerConnection 介面屬於非同步介面,即系統會先返回一個 InstanceId,但該 VPC 對等串連執行個體並未建立完成,系統背景建立任務仍在進行。您可以調用 GetVpcPeerConnectionAttribute 查詢 VPC 對等串連的狀態。
    • 當 VPC 對等串連處於 Creating 狀態時,表示 VPC 對等串連正在建立中。

    • 當 VPC 對等串連處於 Activated 狀態時,表示 VPC 對等串連建立完成。

    • 當 VPC 對等串連處於 Accepting 狀態時,為跨帳號情境,跨帳號情境需要在接收端接收。

  • CreateVpcPeerConnection 介面不支援在同一個 VPC 下並發建立 VPC 對等串連。

建立 VPC 對等串連時,系統會為您自動開通非跨境雲資料轉送 CDT(Cloud DataTransfer)功能。

調試

您可以在OpenAPI Explorer中直接運行該介面,免去您計算簽名的困擾。運行成功後,OpenAPI Explorer可以自動產生SDK程式碼範例。

調試

授權資訊

下表是API對應的授權資訊,可以在RAM權限原則語句的Action元素中使用,用來給RAM使用者或RAM角色授予調用此API的許可權。具體說明如下:

  • 操作:是指具體的許可權點。

  • 存取層級:是指每個操作的存取層級,取值為寫入(Write)、讀取(Read)或列出(List)。

  • 資源類型:是指操作中支援授權的資源類型。具體說明如下:

    • 對於必選的資源類型,用前面加 * 表示。

    • 對於不支援資源級授權的操作,用全部資源表示。

  • 條件關鍵字:是指雲產品自身定義的條件關鍵字。

  • 關聯操作:是指成功執行操作所需要的其他許可權。操作者必須同時具備關聯操作的許可權,操作才能成功。

操作

存取層級

資源類型

條件關鍵字

關聯操作

vpc:CreateVpcPeerConnection

create

*全部資源

*

請求參數

名稱

類型

必填

描述

樣本值

RegionId

string

需要建立 VPC 對等串連的地區 ID。

您可以通過調用 DescribeRegions 介面擷取地區 ID。

cn-hangzhou

VpcId

string

需要建立 VPC 對等串連發起端的 VPC ID。

vpc-bp1gsk7h12ew7oegk****

AcceptingAliUid

integer

需要建立的 VPC 對等串連接收端的阿里雲帳號(主帳號)ID。

  • 輸入您的阿里雲帳號 ID,則建立同帳號 VPC 對等串連。

  • 輸入其他阿里雲帳號 ID,則建立跨帳號 VPC 對等串連。

說明

如果接收端的帳號為 RAM 使用者(子帳號),則 AcceptingAliUid 需要輸入該 RAM 使用者對應的阿里雲帳號 ID。

1210123456123456

AcceptingRegionId

string

需要建立的 VPC 對等串連接收端的地區 ID。

  • 建立同地區 VPC 對等串連時,輸入與發起端的地區 ID 相同的地區 ID。

  • 建立跨地區 VPC 對等串連時,輸入與發起端的地區 ID 不同的地區 ID。

cn-hangzhou

AcceptingVpcId

string

VPC 對等串連接收端的 VPC ID。

vpc-bp1vzjkp2q1xgnind****

Name

string

需要建立的 VPC 對等串連名稱。

名稱長度為 2~128 個字元,以英文字母或中文開頭,可包含數字、底線(_)和短劃線(-)。

vpcpeer

Description

string

需要建立的 VPC 對等串連描述資訊。

長度為 2~256 個字元,必須以字母或中文開頭,但不能以http://https://開頭。

description

DryRun

boolean

是否只預檢此次請求。取值:

  • true:發送檢查請求,不會建立 VPC 對等串連。檢查項包括是否填寫了必需參數、請求格式、業務限制。如果檢查不通過,則返回對應錯誤。如果檢查通過,則返回錯誤碼DryRunOperation

  • false(預設值):發送正常請求,通過檢查後返回 HTTP 2xx 狀態代碼並直接進行操作。

false

ClientToken

string

用戶端 Token,用於保證請求的等冪性。

由用戶端產生該參數值,要保證在不同請求間唯一,最大值不超過 64 個 ASCII 字元。

說明

若您未指定,則系統自動使用 API 請求的 RequestId 作為 ClientToken 標識。每次 API 請求的 RequestId 可能不一樣。

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

ResourceGroupId

string

資源群組 ID。

關於資源群組的更多資訊,請參見什麼是資源群組

rg-acfmxazb4ph6aiy****

Bandwidth

integer

需要建立的 VPC 對等串連的頻寬值,單位:Mbps,取值範圍為大於 0 的整數。

說明

如需指定該參數,請確保您建立的是跨地區的對等串連。

100

LinkType

string

鏈路類型。

可選值為 Platinum(鉑金),Gold(金),預設為 Gold(金)。

說明

如需指定該參數,請確保您建立的是跨地區的對等串連。

Gold

Tag

array<object>

標籤資訊。

object

標籤資訊。

Key

string

資源的標籤鍵。至少輸入 1 個標籤鍵,最多支援輸入 20 個標籤鍵。一旦傳入該值,則不允許為空白字串。

最多支援 128 個字元,不能以aliyunacs:開頭,不能包含http://或者https://

FinanceDept

Value

string

資源的標籤值。至少輸入 1 個標籤值,最多支援輸入 20 個標籤值。一旦傳入該值,可以為空白字串。

最多支援 128 個字元,不能以aliyunacs:開頭,不能包含http://或者https://

FinanceJoshua

返回參數

名稱

類型

描述

樣本值

object

請求 ID。

RequestId

string

請求 ID。

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

InstanceId

string

建立的 VPC 對等串連的執行個體 ID。

pcc-lnk0m24khwvtkm****

樣本

正常返回樣本

JSON格式

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

錯誤碼

HTTP status code

錯誤碼

錯誤資訊

描述

400 OperationFailed.CdtNotOpened The operation failed because the Cdt service is not opened. 建立操作失敗,因為未開通Cdt服務
400 OperationFailed.CrossBorderCdtNotOpened The operation failed because the CrossBorderCdt service is not opened. 操作失敗,因為未開啟CrossBorderCdt服務。
400 IncorrectStatus.Vpc The status of %s [%s] is incorrect. 發起端VPC執行個體狀態不正確。
400 IncorrectStatus.AcceptingVpc The status of %s [%s] is incorrect. 接收端VPC狀態不正確。
400 ResourceAlreadyExist.RouterInterface The specified resource of %s already exists. 指定的路由器介面已經存在
400 ResourceAlreadyExist.VpcPeer The specified resource of %s already exists. 指定的VpcPeer已經存在
400 OperationDenied.CloudBoxExistsInVpc The operation is not allowed because the CloudBox device exists in vpc. 在發起端VPC記憶體在雲盒執行個體,因此不允許建立VpcPeer執行個體。
400 OperationDenied.CloudBoxExistsInAcceptingVpc The operation is not allowed because the CloudBox device exists in accepting vpc. 在接收端VPC記憶體在雲盒執行個體,因此不允許建立VpcPeer執行個體。
400 QuotaExceeded.VpcPeerCountPerVpc The quota of %s is exceeded, usage %s/%s. 指定VPC中的VpcPeer數量超出限制
400 UnsupportedRegion The feature of %s is not supported in the region of %s. VpcPeer特性在此地區不支援
400 QuotaExceeded.VpcPeerCountPerUserPerRegion The quota of %s is exceeded, usage %s/%s. 單個地區內VpcPeer執行個體數量超過閾值。
400 IncorrectBusinessStatus.VpcPeer The business status of %s [%s] is incorrect. 當前執行個體狀態異常,不允許進行當前操作
400 OperationFailed.NotExist.ResourceGroup 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. 對端Cdt服務未開通,操作失敗。
400 OperationFailed.AcceptUserCrossBorderCdtNotOpened The operation failed because the CrossBorderCdt service of accept user is not opened. 對端跨境Cdt服務未開通,操作失敗。
400 IncorrectBusinessStatus.AcceptUserVpcPeer The business status of %s [%s] is incorrect. 對端VpcPeer商業狀態異常。
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. 建立操作失敗是因為不允許建立發起地區與接受地區之間的vpc peer執行個體。
400 QuotaExceeded.CrossRegionVpcPeerCountPerVpc The quota of %s is exceeded, usage %s/%s. 指定VPC中的跨地區VpcPeer數量超出限制
400 QuotaExceeded.IntraRegionVpcPeerCountPerVpc The quota of %s is exceeded, usage %s/%s. 指定VPC中的同地區VpcPeer數量超出限制
400 OperationDenied.OperateShareResource The operation is not allowed because of operating shared resource. 操作共用資源導致操作失敗
400 IncorrectBusinessStatus.AcceptVpcPeer The business status of peer account is incorrect. 對端VpcPeer商業狀態異常。
400 OperationFailed.InterRegionLinkTypeNotSupported The same region not supported link type feature. 同地區不支援鏈路類型特性
400 OperationFailed.RegionIdNotSupportLinkType The feature link type is not supported in the region. 地區不支援該特性金銀銅設定
400 OperationFailed.SpecificLinkTypeNotSupported The operation failed because the special link type of user is not opened. 該帳號不支援特殊鏈路類型

訪問錯誤中心查看更多錯誤碼。

變更歷史

更多資訊,參考變更詳情