This topic describes how to use Alibaba Cloud SDK for Python to associate an elastic IP address (EIP) with an EIP bandwidth plan.
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 an EIP in the China (Hangzhou) region.
- Create an EIP bandwidth plan in the China (Hangzhou) region.
- Associate the EIP with the EIP bandwidth plan.
- Query the EIP bandwidth plan.
- Disassociate the EIP from the EIP bandwidth plan.
- Delete the EIP bandwidth plan.
- Release the EIP.
Procedure
Result
The following output is returned:
---------------------------allocate_eip_address---------------------------
{
"EipAddress": "118.XX.XX.198",
"ResourceGroupId": "rg-acfm4od****",
"RequestId": "A830A607-B7C4-49FE-A6EE-7237D64CDE2D",
"AllocationId": "eip-bp1mdyvr22qvg****"
}
---------------------------create_common_bandwidth_package----------------------
-----
{
"ResourceGroupId": "rg-acfm4od****",
"BandwidthPackageId": "cbwp-bp12k058pjjie****",
"RequestId": "93127320-DD79-4F83-A3B9-DC99D0597B0C"
}
---------------------------add_common_bandwidth_packageIp-----------------------
----
{
"RequestId": "7F314AFE-B398-4348-AF61-B7D27B731286"
}
---------------------------add_common_bandwidth_packageIp-----------------------
----
{
"TotalCount": 1,
"CommonBandwidthPackages": {
"CommonBandwidthPackage": [
{
"Status": "Available",
"PublicIpAddresses": {
"PublicIpAddresse": [
{
"IpAddress": "118.XX.XX.198",
"AllocationId": "eip-bp1mdyvr22qvg****"
}
]
},
"BusinessStatus": "Normal",
"RegionId": "cn-hangzhou",
"BandwidthPackageId": "cbwp-bp12k058pjjie****",
"Name": "",
"ISP": "BGP",
"CreationTime": "2019-04-18T01:46:17Z",
"ResourceGroupId": "rg-acfm4od****",
"Bandwidth": "10",
"InstanceChargeType": "PostPaid",
"HasReservationData": false,
"InternetChargeType": "PayByBandwidth",
"ExpiredTime": "",
"Ratio": 100,
"Description": ""
}
]
},
"PageNumber": 1,
"RequestId": "015DD0FA-742B-4431-92EA-E3F03FDEB8CD",
"PageSize": 10
}
---------------------------remove_common_bandwidth_packageIp--------------------
-------
{
"RequestId": "A49C9126-B703-4D34-B552-A7FE283FB5DD"
}
---------------------------delete_common_bandwidth_package----------------------
-----
{
"RequestId": "E423F648-C169-4B63-A2CF-5E6C8E441DE1"
}
---------------------------release_eip_address---------------------------
{
"RequestId": "7E0D34AE-58C3-468A-B021-378F8938AE6B"
}