The Alibaba Cloud Command Line Interface (CLI) is a unified tool to manage your Alibaba Cloud services. With just one tool to download and configure, you can control multiple Alibaba Cloud services from the command line and automate them through scripts.
The CLI uses the SDK of various products internally to achieve the intended results. This installation can be hard to maintain considering the frequent releases of new SDK versions. This can also be cumbersome if you don't have access to a machine with the pre-requisites installed.
Docker comes in handy in this situation. The key benefit of Docker is that it allows users to package an application with all its dependencies into a standardized unit for software development. Unlike virtual machines, containers do not have the high overhead and hence enable more efficient usage of the underlying system and resources.
This document explains a pre-packaged Alibaba Cloud CLI Docker image that could be used to launch the CLI at will. It also discusses a way to make the container data persistent.
To get started, the Alibaba Cloud CLI Docker image needs to be fetched. Depending on your use case run one of the commands below (this will also fetch the latest image if one had not been fetched earlier):
docker run -ti aliyunca/aliyuncli-python-toolbox:latest sh
docker run -dti aliyunca/aliyuncli-python-toolbox:latest sh
For both of these invocations, the CLI must then be configured:
# configure the CLI
$ aliyuncli configure
Aliyun Access Key ID [None]: my_access_id
Aliyun Access Key Secret [None]: mypassword
Default Region Id [None]:
Default output format [None]:
# make calls to Aliyun!
$ aliyuncli ecs
usage: aliyuncli <command> <operation> [options and parameters]
[ecs] valid operations as follows:
ActivateRouterInterface | AddTags
AllocateEipAddress | AllocatePublicIpAddress
ApplyAutoSnapshotPolicy | AssociateEipAddress
AssociateHaVip | AttachDisk
....
# get some help regarding the function
aliyuncli ecs DescribeImages help
Note: The docker image can be configured to have the initial CLI configuration to be persisted. This should only be done in computers that the user has trust in. The parameter highlighted needs to be replaced.
Run the below command to pass the local folder reference that will store the CLI parameters
docker run -dti \
-v {Full local folder path}:/root/.aliyuncli \
aliyunca/aliyuncli-python-toolbox:latest sh
Environmental variables are also honored:
docker run -dti \
--env ALI_ACCESS_KEY={API Key} \
--env ALI_ACCESS_SECRET={API Secret} \
--env ALI_DEFAULT_REGION=ap-southeast-1 \
--env ALI_OUTPUT_FORMAT=json \
aliyunca/aliyuncli-python-toolbox:latest sh
This document explains a simple way to access the Alibaba Cloud CLI without going through the complexities of maintaining an environment on its own. This will also free the host computer from the dependencies that will be installed as part of the CLI installation.
Load Balancing MySQL Database with Read Replicas on Alibaba Cloud
Using an ApsaraDB for RDS Client with Auto-Completion Features
Alibaba Clouder - October 29, 2018
- September 5, 2017
Alibaba Clouder - August 19, 2019
Apache Flink Community China - December 25, 2019
GhulamQadir - January 15, 2020
Alibaba Clouder - June 2, 2020
Elastic and secure virtual cloud servers to cater all your cloud hosting needs.
Learn MoreAn agile and secure serverless container instance service.
Learn MoreEMAS HTTPDNS is a domain name resolution service for mobile clients. It features anti-hijacking, high accuracy, and low latency.
Learn MoreAlibaba Cloud Container Service for Kubernetes is a fully managed cloud container management service that supports native Kubernetes and integrates with other Alibaba Cloud products.
Learn MoreMore Posts by Sabith