This topic describes how to use Alibaba Cloud SDK for Python to connect two virtual private clouds (VPCs) that belong to the same region and Alibaba Cloud account.
Prerequisites
Before you use Alibaba Cloud SDK for Python, make sure that the following requirements
are met:
- An Alibaba Cloud account and the AccessKey pair are obtained. You can create and view your AccessKey pair on the Security Management page of the Alibaba Cloud Management Console.
- Make sure that Alibaba Cloud SDK for Python is installed. For more information, see aliyun-python-sdk-vpc 3.0.12.
- The VPC Python example library is downloaded.
Go to the directory where the setup.py file is stored, and run the following command to initialize the environment:
python setup.py install
Background information
When you create a router interface, take note of the following limits:
- You can create only one pair of interfaces to be connected between two routers.
- You can create at most five interfaces for each router.
- If your Alibaba Cloud account has a router interface with overdue payments, you cannot create new router interfaces.
- The destination CIDR blocks of route entries in the same route table must be unique.
Procedure
Result
The following output is returned:
---------------------------create_router_interface---------------------------
{
"RequestId": "F5493DC1-53B0-4916-874F-87773A54525F",
"RouterInterfaceId": "ri-bp1ujwb6xsw16****"
}
---------------------------create_router_interface---------------------------
{
"RequestId": "E3F5BE99-B2C5-4751-8173-0F590300EE72",
"RouterInterfaceId": "ri-bp1vze2rusg2c****"
}
---------------------------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-bp141no9pds2b****",
"Spec": "Large.2",
"Status": "Idle",
"EndTime": "2999-09-08T16:00:00Z",
"OppositeInterfaceSpec": "Negative",
"RouterInterfaceId": "ri-bp1ujwb6xsw16****",
"RouterType": "VRouter",
"OppositeBandwidth": 0,
"OppositeVpcInstanceId": "vpc-bp1v31by9jix2****",
"HasReservationData": false,
"OppositeInterfaceBusinessStatus": "Normal",
"OppositeRouterType": "VRouter",
"OppositeRegionId": "cn-hangzhou",
"VpcInstanceId": "vpc-bp15opprpg0rg****",
"RouterId": "vrt-bp1ltkytn6lgm****",
"CrossBorder": false,
"OppositeInterfaceOwnerId": "",
"Bandwidth": 2048,
"OppositeInterfaceId": "ri-bp1vze2rusg2c****",
"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-bp1ltkytn6lgm****",
"VpcInstanceId": "vpc-bp1v31by9jix2****",
"RouterInterfaceId": "ri-bp1vze2rusg2c****",
"CreationTime": "2019-04-30T06:09:18Z",
"RouterType": "VRouter",
"OppositeInterfaceOwnerId": "",
"RouterId": "vrt-bp141no9pds2b****",
"Bandwidth": 0,
"OppositeInterfaceId": "ri-bp1ujwb6xsw16****",
"EndTime": "2999-09-08T16:00:00Z",
"ChargeType": "AfterPay",
"OppositeVpcInstanceId": "vpc-bp15opprpg0rg****",
"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"
}