- Introduction
- Use Cases
- Prerequisites
- Prepare ECS Cost Estimation CSV Templates
- How to use Python code snippets
- Support
This example shows how to use Alibaba Cloud Billing API using python for estimating ECS subscription or PayAsYouGo using csv template.
We will demonstrate 2 use cases.
This is a common use case where in there is a need to estimate Subscription cost (Monthly/Yearly) for large number of ECS based on different combinations (instance family,System Disk,Data Disk, Region, Disk type, duration(monthly, yearly) etc)
This is a common use case where in there is a need to estimate PayAsYouGo cost (Monthly/Yearly) for large number of ECS based on different combinations (instance family,System Disk,Data Disk, Region, Disk type, duration(hourly, days) etc)
Set up python environment on your local machine (mac).
prompt:~$ brew install python
prompt:~$ python -m pip install aliyun-python-sdk-bssopenapi
prompt:~$ python -m pip install bs4
This particular Python Billing programs requires input in a certain format.
Please use this template to pass in as input to python program for ECS subscription cost estimate.
ecs_subscription_cost_estimation_template.csv
Input File
Please use this template to pass in as input to python program for ECS PayAsYouGo cost estimate.
ecs_payasyougo_cost_estimation_template.csv
Input File
-
Make sure you have python environment setup and templates ready as mentioned in Step3.
-
Copy ecs_subscription_cost_estimation.py & ecs_subscription_cost_estimation_template.csv to a folder.
-
Update the code file with your respective keys (AccessKey ID,Access Secret Key) and save it.
-
Execute python ecs_subscription_cost_estimation.py
-
Check the out file ecs_subscription_cost_estimation_output_xxxxxxxxxxxxxx.csv with the cost.
-
Make sure you have python environment setup and templates ready as mentioned in Step3.
-
Copy ecs_payasyougo_cost_estimation.py & ecs_payasyougo_cost_estimation_template.csv to a folder.
-
Update the code file with your respective keys (AccessKey ID,Access Secret Key) and save it.
-
Execute python ecs_payasyougo_cost_estimation.py
-
Check the out file ecs_payasyougo_cost_estimation_output_xxxxxxxxxxxxxx.csv
Don't hesitate to contact us if you have questions or remarks.