[Reprint from ken's post]
1. AliCloud API overview
AliCloud API is a powerful abstraction of interacting the entire cloud infrastructure in a programmable fashion. 90% of the tasks that we can perform through the web console can also be achieved through API calls. This allows system administrators and developers to raise their productivity and embed automation in their day-to-day operation activities.
In order to connect to AliCloud API endpoints, we first need to obtain a pair of Access Key Secret, which is described next below.
2. Access Key Pair Generation
a. Login to the Web Console GUI:
- Click on the Console link on the top panel from the main website (www.alicloud.com)
- Login with your account username and password:
b. Once you are in the Web Console GUI, click on the ‘AccessKeys’ from the top panel
c. On the newly launched page, click “Create AccessKey” on the top right corner
d. Follow the prompted steps, including a step where you may have to click a link in the pop-out window to send a SMS to your registered mobile number with the confirmation 6-digit code.
e. After creation, we should see the key pair as below, with the Access Key Secret hidden
f. Click “Show” to obtain the key secret
g. Make a copy of the Access Key ID and Access Key Secret. We will need them in the next steps of setting up the environment. Please don’t share with anyone else as this would allow API calls across your cloud infrastructure (as we will see later).
3. Python SDK
AliCloud has integrated with various popular SDK: Java, Python, PHP, while many are being actively developed.
For this tutorial, we will use the Python SDK, and we are going to install the SDK for AliCloud OSS
a. Prerequisite: Python 2.7+
b. Install ‘pip’ for managing Python package dependencies management.
c. Use ‘pip’ to install the following AliCloud core packages:
>> pip install aliyun-python-sdk-core
>> pip install aliyun-python-sdk-oss
Please note that the above environment can be configured on ANY machines , it doesn’t have to be on any ECS instance running on the AliCloud.
4. Aliyuncli
Aliyuncli is built on top of the above core Python AliCloud packages, which provides a simple command line interface to interact with AliCloud infrastructure resources. Instead of writing your own programs from scratch, aliyuncli delivers a ready-to-use toolkit that wraps around most of the essential functions.
a. Use pip to install package ‘aliyuncli’
>> pip install aliyuncli
b. Configure ‘aliyuncli’ with the pair of Access Key obtained above by running the command, to setup the authentication parameters
>> aliyuncli oss Config --host oss.aliyuncs.com --accessid ***********Em --accesskey ***********0Dr
版权声明:本文内容由阿里云实名注册用户自发贡献,版权归原作者所有,阿里云开发者社区不拥有其著作权,亦不承担相应法律责任。具体规则请查看《阿里云开发者社区用户服务协议》和《阿里云开发者社区知识产权保护指引》。如果您发现本社区中有涉嫌抄袭的内容,填写侵权投诉表单进行举报,一经查实,本社区将立刻删除涉嫌侵权内容。
Ken's post provides a comprehensive guide to getting started with Alibaba Cloud API usage, focusing on accessing the API, generating access key pairs, setting up the Python SDK for interacting with AliCloud Object Storage Service (OSS), and using the aliyuncli
command-line tool. Here's a summary and some additional context:
The AliCloud API enables users to programmatically manage their cloud resources, replicating most tasks available in the web console. This is crucial for automation, enhancing productivity, and integrating cloud services into your applications or IT operations.
aliyun-python-sdk-core
and aliyun-python-sdk-oss
). Note that these installations can be done on any machine with Python, not necessarily an ECS instance within Alibaba Cloud.aliyuncli
package via pip, which offers a CLI interface for managing AliCloud resources.aliyuncli
with your Access Key ID and Secret obtained earlier. The example command sets up the CLI to interact with OSS services.Additional Tips: - Security Best Practices: Keep your Access Key Secret secure and rotate keys periodically for security reasons. - Python Version: It's advisable to use Python 3 instead of Python 2.7 since Python 2 reached its end-of-life and no longer receives updates or support. - SDK Updates: Always check for the latest versions of the SDKs and tools before installing, as technology evolves rapidly. - CLI Usage: aliyuncli
simplifies many tasks but explore its documentation for the full range of commands and options available for different services.
By following Ken's steps, you'll have set up the foundation for programmatically managing your Alibaba Cloud infrastructure using Python SDK or the command line, enabling efficient automation and control over your resources.