This topic describes how to use Alibaba Cloud SDK for Python to interconnect two VPCs under the same account in the same region.
Prerequisites
Background information
Before you interconnect two VPCs, you must create a router interface for each VPC.
When you create router interfaces, note the following limits:
- Only one pair of interconnected router interfaces can be created between two VRouters.
- A maximum of five router interfaces can be created for each VRouter.
- If a router interface with an overdue payment is under your account, you cannot create router interfaces.
- Route entries in the same route table cannot have the same destination CIDR blocks.
The example used in this topic includes the following steps:
- Create an initiator router interface.
- Create an acceptor router interface.
- Modify the initiator router interface.
- Modify the acceptor router interface.
- Query the initiator router interface.
- Query the acceptor router interface.
- Connect the initiator router interface to the acceptor router interface.
- Create a route entry whose next hop is the initiator router interface.
- Create a route entry whose next hop is the acceptor router interface.
- Delete the route entry whose next hop is the acceptor router interface.
- Delete the route entry whose next hop is the initiator router interface.
- Deactivate the initiator router interface.
- Deactivate the acceptor router interface.
- Delete the initiator router interface.
- Delete the acceptor router interface.
Procedure
Result
The system output is displayed as follows:
---------------------------create_router_interface---------------------------
{
"RequestId": "F5493DC1-53B0-4916-874F-87773A54525F",
"RouterInterfaceId": "ri-bp1ujwb6xsw16xxxxxxxx"
}
---------------------------create_router_interface---------------------------
{
"RequestId": "E3F5BE99-B2C5-4751-8173-0F590300EE72",
"RouterInterfaceId": "ri-bp1vze2rusg2cxxxxxxxx"
}
---------------------------modify_router_interface_attribute---------------------------
{
"RequestId": "8D691507-F31A-41E5-9C72-457EFF1F7727"
}
---------------------------modify_router_interface_attribute---------------------------
{
"RequestId": "2E664208-8F37-4F19-B719-00B4F1AF03B2"
}
---------------------------describe_router_interface---------------------------
{
"TotalCount": 1,
"RouterInterfaceSet": {
"RouterInterfaceType": [
{
"BusinessStatus": "Normal",
"CreationTime": "2019-04-30T06:09:16Z",
"Role": "InitiatingSide",
"OppositeRouterId": "vrt-bp141no9pds2bxxxxxxxx",
"Spec": "Large.2",
"Status": "Idle",
"EndTime": "2999-09-08T16:00:00Z",
"OppositeInterfaceSpec": "Negative",
"RouterInterfaceId": "ri-bp1ujwb6xsw16xxxxxxxx",
"RouterType": "VRouter",
"OppositeBandwidth": 0,
"OppositeVpcInstanceId": "vpc-bp1v31by9jix2xxxxxxxx",
"HasReservationData": false,
"OppositeInterfaceBusinessStatus": "Normal",
"OppositeRouterType": "VRouter",
"OppositeRegionId": "cn-hangzhou",
"VpcInstanceId": "vpc-bp15opprpg0rgxxxxxxxx",
"RouterId": "vrt-bp1ltkytn6lgmxxxxxxxx",
"CrossBorder": false,
"OppositeInterfaceOwnerId": "",
"Bandwidth": 2048,
"OppositeInterfaceId": "ri-bp1vze2rusg2cxxxxxxxx",
"ChargeType": "AfterPay"
}
]
},
"PageNumber": 1,
"RequestId": "89EF0631-0A36-41AD-A586-AF4FFDA6E68B",
"PageSize": 10
}
---------------------------describe_router_interface---------------------------
{
"TotalCount": 1,
"RouterInterfaceSet": {
"RouterInterfaceType": [
{
"Status": "Idle",
"OppositeRegionId": "cn-hangzhou",
"BusinessStatus": "Normal",
"OppositeRouterId": "vrt-bp1ltkytn6lgmxxxxxxxx",
"VpcInstanceId": "vpc-bp1v31by9jix2xxxxxxxx",
"RouterInterfaceId": "ri-bp1vze2rusg2cxxxxxxxx",
"CreationTime": "2019-04-30T06:09:18Z",
"RouterType": "VRouter",
"OppositeInterfaceOwnerId": "",
"RouterId": "vrt-bp141no9pds2bxxxxxxxx",
"Bandwidth": 0,
"OppositeInterfaceId": "ri-bp1ujwb6xsw16xxxxxxxx",
"EndTime": "2999-09-08T16:00:00Z",
"ChargeType": "AfterPay",
"OppositeVpcInstanceId": "vpc-bp15opprpg0rgxxxxxxxx",
"HasReservationData": false,
"CrossBorder": false,
"OppositeInterfaceBusinessStatus": "Normal",
"Spec": "Negative",
"OppositeRouterType": "VRouter",
"Role": "AcceptingSide"
}
]
},
"PageNumber": 1,
"RequestId": "578448D7-9DCF-4703-8337-EF88DDF2C325",
"PageSize": 10
}
---------------------------connect_router_interface---------------------------
{
"RequestId": "A5DBB86B-F6F5-4A53-899E-8CF4FEF510F2"
}
---------------------------create_route_entry---------------------------
{
"RequestId": "70D896FE-986B-48EF-9734-17D6BDC8327A"
}
---------------------------create_route_entry---------------------------
{
"RequestId": "A2233E25-4D6B-4713-A96F-E7CA745973CA"
}
---------------------------delete_route_entry---------------------------
{
"RequestId": "464C62A4-EE65-4414-AF0A-4984AE6B8696"
}
--------------------------delete_route_entry---------------------------
{
"RequestId": "0C11A332-969B-47CA-A683-5BFFECA28B3D"
}
---------------------------deactivate_router_interface---------------------------
{
"RequestId": "018305AD-FB9E-450A-91E8-3830634F5AC2"
}
---------------------------deactivate_router_interface---------------------------
{
"RequestId": "89B03203-9224-4CA3-8679-E0A49029A2D2"
}
---------------------------delete_router_interface---------------------------
{
"RequestId": "FB0424CE-D0C7-438B-A3FA-BCF24EE9CC8A"
}
---------------------------delete_router_interface---------------------------
{
"RequestId": "8A0A0BB6-A69D-461B-A117-14AD6670DECA"
}