Cloud Shell provides a pre-installed Alibaba Cloud CLI environment. Run CLI commands directly from your browser to manage Alibaba Cloud resources.
Prerequisites
Review the following before using Alibaba Cloud CLI in Cloud Shell:
-
Alibaba Cloud CLI is a management tool built on Alibaba Cloud OpenAPI. What is Alibaba Cloud CLI?
-
Use a RAM identity (such as a RAM user or a RAM role) with the required permissions to access Cloud Shell. Identity-based policies.
-
Cloud Shell updates its pre-installed CLI a few days after each new release. Run
aliyun versionto check the current version or manually install a different one.
Procedure
Step 1: Start Cloud Shell
Log on to Alibaba Cloud with a RAM identity that has the required permissions. Cloud Shell uses your current session to configure credentials. Do not modify or delete the initial default profile.
Start Cloud Shell using one of these methods:
-
From the console
Click the Cloud Shell icon in the top navigation bar of the Alibaba Cloud Management Console.
-
From its web page
Go to https://shell.aliyun.com in your browser.
-
First-time startup provisions a dedicated virtual machine, which takes up to 30 seconds.
-
You can open up to five windows simultaneously. All windows share the same virtual machine.
Step 2: Get a CLI command
Automatic generation
OpenAPI Explorer generates CLI commands online. Use it to get command examples. Generate a command.
On the API Debugging page, search for the target API in the search box on the left. Enter the parameters on the Parameter Configuration tab, then click the CLI Example tab next to Parameter Configuration to generate a command with those parameters.
-
Click Run Command in CloudShell
to run the command in Cloud Shell directly. -
Click Copy
to copy the command to your clipboard, then paste and run it in Cloud Shell.
Manual composition
Alibaba Cloud APIs are either RPC or RESTful. Most products (ECS, ApsaraDB RDS, load balancer) use RPC APIs.
Identify the API type by these characteristics:
-
RPC APIs include an Action parameter, while RESTful APIs require a PathPattern parameter.
-
Typically, all API operations for a single cloud product are of the same type.
Understand the command structure.
Get help
-
List API operations for a product:
aliyun <ProductCode> --helpExample: list ECS API operations:
aliyun ecs --help -
View help for a specific API operation:
aliyun <ProductCode> <ApiName> --helpExample: view help for ECS
DescribeInstanceAttribute:aliyun ecs DescribeInstanceAttribute --help
Step 3: Run a command
The following CreateInstance command creates a pay-as-you-go Elastic Compute Service instance:
shell@Alicloud:~$ aliyun ecs CreateInstance\
> --InstanceName myvm1\
> --ImageId centos_7_03_64_40G_alibase_20170625.vhd\
> --InstanceType ecs.n4.small\
> --SecurityGroupId sg-xxx123\
> --VSwitchId vsw-xxx456\
> --InternetChargeType PayByTraffic\
> --Password