This topic describes how to use Alibaba Cloud SDK for Python to create a custom route table.
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
- Create a virtual private cloud (VPC) in the China (Zhangjiakou) region.
- Create a vSwitch in the VPC.
- Create a custom route table named sdk_route_table.
- Query the vSwitch.
- Associate the custom route table with the vSwitch that belongs to the same VPC.
- Disassociate the custom route table from the vSwitch that belongs to the same VPC.
- Delete the custom route table.
- Delete the vSwitch.
- Delete the VPC.
Procedure
Result
The following output is returned:
---------------------------create_vpc---------------------------
{
"ResourceGroupId": "rg-acfmxazxxxxxxxx",
"RouteTableId": "vtb-8vb65a5hqy8pcxxxxxxxx",
"VRouterId": "vrt-8vbbbiftzizc3xxxxxxxx",
"VpcId": "vpc-8vbebihln001gxxxxxxxx",
"RequestId": "862F279B-4A27-4300-87A1-047FB9961AF2"
}
---------------------------create_vswitch---------------------------
{
"VSwitchId": "vsw-8vb30klhn2is5xxxxxxxx",
"RequestId": "1DA17173-CB61-4DCE-9C29-AABFDF3001A6"
}
---------------------------create_route_table---------------------------
{
"RouteTableId": "vtb-8vbc4iwpo13apxxxxxxxx",
"RequestId": "01E66E67-7801-4705-A02A-853BA7EEA89F"
}
---------------------------describe_vswitch_attribute---------------------------
{
"Status": "Available",
"NetworkAclId": "",
"VpcId": "vpc-8vbebihln001gxxxxxxxx",
"Description": "",
"RouteTable": {
"RouteTableId": "vtb-8vb65a5hqy8pcxxxxxxxx",
"RouteTableType": "System"
},
"CidrBlock": "172.16.0.0/16",
"CreationTime": "2019-04-12T03:08:43Z",
"CloudResources": {
"CloudResourceSetType": []
},
"ZoneId": "cn-zhangjiakou-b",
"ResourceGroupId": "rg-acfmxazbxxxxxxxx",
"VSwitchId": "vsw-8vb30klhn2is5xxxxxxxx",
"RequestId": "C5A20BA3-E998-498D-8900-35AE5FDFFB77",
"Ipv6CidrBlock": "",
"VSwitchName": "",
"AvailableIpAddressCount": 252,
"IsDefault": false
}
---------------------------associate_route_table---------------------------
{
"RequestId": "5FC0143B-D34B-47DC-8D49-AFD222EA5876"
}
---------------------------unassociate_route_table---------------------------
{
"RequestId": "F0194718-6E4C-496C-9DA8-1B88DF1D6FAD"
}
---------------------------delete_route_table---------------------------
{
"RequestId": "B5C068A6-137C-4337-8E3A-9E30E1726703"
}
---------------------------delete_vswitch---------------------------
{
"RequestId": "26DEDBF8-2F0D-4A13-8CB3-23A84C947704"
}
---------------------------delete_vpc---------------------------
{
"RequestId": "E1B2641F-5911-40E4-9F36-CC0B2EDD1747"
}