Alibaba Cloud CLI command parameters are classified into global flags that control CLI behavior and business parameters that are passed to subcommands. This topic describes how to view available parameters, format parameter values of various data types, and use the auto-completion feature.
Prerequisites
Alibaba Cloud CLI 3.3.0 or later is installed. For installation instructions, see Install, update, and uninstall Alibaba Cloud CLI. If your current version is earlier than 3.3.0, see Migrate from legacy to plugin-based CLI to complete the migration.
Credentials are configured for Alibaba Cloud CLI. For configuration instructions, see Configure and manage credentials.
Parameter types
A CLI command consists of a command, a subcommand, and parameters:
aliyun <command> <sub-command> [parameters]Parameters are classified into two types:
Global flags: Control the behavior of the CLI itself, such as region selection, output format, and pagination. Global flags apply to all commands.
Business parameters: Request fields that are passed to subcommands. Business parameters vary by operation.
In the following example, --help is a global flag and --biz-region-id is a business parameter:
aliyun ecs describe-instances --help
aliyun ecs describe-instances --biz-region-id cn-hangzhouGlobal flags
The following flags apply to all plugin commands, including specifying a region, paginating query results, and enabling dry-run mode:
Flag | Type | Description |
| string | Specifies the region ID, such as |
| string | Specifies the API endpoint URL. In most cases, you do not need to manually set this flag. |
| string | Filters output by using a JMESPath expression. |
| list | Automatically aggregates all paginated API results. |
| bool | Dry-run mode: validates parameters and prints the request content without actually sending the request. For plugin commands, use this flag instead of the legacy |
| bool | AI-assisted mode. When enabled, an AI identifier is added to the User-Agent header of the current API request. |
| string | Sets the log output level for debugging and troubleshooting. Valid values: |
| bool | Quiet mode: suppresses the API response output. This flag is suitable for scripting and CI/CD scenarios. |
| bool | Displays help information. |
--cli-dry-run is mutually exclusive with --pager and --quiet. These flags cannot be used together because dry-run mode does not send actual requests.
Business parameters
Business parameters are request fields that are passed to subcommands. Different operations have different business parameters.
aliyun ecs describe-instances --biz-region-id cn-hangzhou --cli-dry-runThe data types of business parameters are defined by APIs. Common types include:
String: A text string, such as an instance ID or name.
Integer: A whole number, such as a page number or count.
Boolean: A Boolean value of
trueorfalse.Array / JSON: An array or JSON object, such as a list of disk IDs or a tag object.
Discover parameters
You can view the parameters that a command supports by using CLI help information or the online OpenAPI portal.
Use CLI help information
Append --help to a command to view all supported parameters and their descriptions. The format of help output varies by command type.
Built-in commands
Built-in commands are integrated into the Alibaba Cloud CLI core program and can be used directly without installing additional plugins, such as configure. The help output for built-in commands displays subcommands or specific options:
aliyun configure --helpHelp output:
configure credential and settings
Usage:
aliyun configure --mode {AK|RamRoleArn|EcsRamRole|OIDC|External|CredentialsURI|ChainableRamRoleArn|CloudSSO|OAuth} --profile <profileName> [--config-path <configPath>]
Commands:
get print configuration values
set set config in non interactive mode
list list all config profile
delete delete the specified profile
switch switch default profile
safety-policy manage safety policy and human-in-the-loop rules
ai-mode manage global AI mode and User-Agent for API calls
plugin-settings manage global plugin system settingsPlugin commands
The help output for cloud service plugin commands displays parameter names in kebab-case format, including parameter types and default values:
aliyun ecs describe-instances --helpHelp output:
Description: Queries a list of instances and their details based on specified conditions
API Version: 2014-05-26
Usage:
aliyun ecs describe-instances [parameters]
Parameters:
--biz-region-id string (required), The ID of the region where the
instance resides. You can call https://help.aliyun.
com/document_detail/25609.html to query the latest
list of Alibaba Cloud regions
--additional-attributes list, The list of other instance attributes
format: --additional-attributes value1 value2 value3
--device-available bool, > This parameter is in invitational preview
and is not available for use
......
Global Flags:
--cli-ai-mode bool, For this run, enable AI-mode
--cli-dry-run bool, Enable dry-run mode: print request details
without sending the actual API call
--cli-query string, Use `--cli-query <jmespath>` to filter
output with JMESPath expression
--endpoint string, Override service endpoint (e.g., --endpoint
https://ecs.cn-hangzhou.aliyuncs.com)
......
Examples:
aliyun ecs describe-instances --biz-region-id example-value
aliyun ecs describe-instances --biz-region-id example-value --vpc-id example-valueUse the OpenAPI portal
The Alibaba Cloud OpenAPI portal allows you to debug APIs online and automatically generates CLI command examples. For more information, see Generate and run CLI commands with OpenAPI Explorer.
Parameter values
The way you pass parameter values varies by data type and operating system environment.
Common type parameter values
Data type | Format | Example |
Integer | Pass the value directly without quotes. |
|
String | Pass the value directly if it does not contain special characters. Enclose the value in quotes if it contains special characters. |
|
Boolean | A flag that enables or disables a feature. For example, including |
|
String list | Separate multiple values with commas and enclose the entire list in quotes. |
|
JSON array | A JSON-formatted string enclosed in quotes. |
|
Date | ISO 8601 format: |
|
Different operating systems and terminal environments handle quotes differently. When passing parameter values that contain special characters, use the following quoting rules:
Environment | General quotes | Quotes for the --body flag |
Linux / macOS | Single quotes | Double quotes |
Windows Command Prompt | Double quotes | Double quotes |
Windows PowerShell | Single quotes | Single quotes |
JSON parameter values
Some command parameters require values in JSON format. The choice of outer quotes and inner quotes varies by operating system.
JSON arrays
Linux / macOS: Use single quotes for the outer layer and double quotes for inner values.
aliyun ecs describe-disks --disk-ids '["d-bp1****","d-bp2****","d-bp3****"]' --biz-region-id cn-hangzhouWindows (Command Prompt and PowerShell): Use double quotes for the outer layer and single quotes for inner values.
aliyun ecs describe-disks --disk-ids "['d-bp1****','d-bp2****','d-bp3****']" --biz-region-id cn-hangzhou
JSON objects
When a parameter value is a JSON object, enclose each JSON object in braces {} and separate keys and values with colons :.
Linux / macOS:
aliyun slb add-backend-servers --load-balancer-id lb-bp1**** --backend-servers '[{"ServerId":"i-bp1****"},{"ServerId":"i-bp2****"}]'Windows (Command Prompt and PowerShell):
aliyun slb add-backend-servers --load-balancer-id lb-bp1**** --backend-servers "[{'ServerId':'i-bp1****'},{'ServerId':'i-bp2****'}]"
Values that contain special characters
Values that start with a hyphen (-)
When a parameter value starts with -, the CLI may misinterpret it as another parameter name:
aliyun ecs AuthorizeSecurityGroup --SecurityGroupId 'sg-bp67acfmxazb4p****' --Permissions.1.PortRange "-1/-1" --method POST --forceUse an equal sign to connect the parameter name and value to resolve this issue:
aliyun ecs AuthorizeSecurityGroup --SecurityGroupId 'sg-bp67acfmxazb4p****' --Permissions.1.PortRange=-1/-1 --method POST --forceShell special characters
When parameter values contain shell special characters ($, `, \, spaces, and so on), you must enclose them in quotes. On Linux / macOS, use single quotes to prevent the shell from interpreting special characters. On Windows Command Prompt, use double quotes.
# Linux/macOS/PowerShell
aliyun ecs describe-images --image-name 'Example Image'
# Windows CMD
aliyun ecs describe-images --image-name "Example Image"
# Linux/macOS
aliyun xxx --param '$literal_dollar'Load parameter values from a file
When a parameter value is long, such as a certificate or a large JSON payload, it is more convenient to load the value from a local file.
--body-file (RESTful API calls)
In RESTful API calls, use --body-file to load the HTTP request body from a local file.
aliyun cs PUT /clusters/c1234****/nodepools/np5678**** --body-file request.jsonShell command substitution and here-doc
You can also use shell command substitution ($(cat ...)) or a here-doc to pass file content to the --body parameter:
# Command substitution
aliyun cs PUT /clusters/c1234****/nodepools/np5678**** --body "$(cat request.json)"
# Here-doc (suitable for constructing inline JSON in scripts)
aliyun cs PUT /clusters/c1234****/nodepools/np5678**** --body "$(cat <<EOF
{
"nodepool_info": {
"name": "default-nodepool",
"resource_group_id": "rg-acfmyvw****"
}
}
EOF
)"Shell command substitution and here-doc are only applicable to bash or zsh environments. For Windows environments, use --body-file.
Command auto-completion
Alibaba Cloud CLI supports command auto-completion. After you enable this feature, you can press Tab to auto-complete product names, operation names, and parameter names.
Auto-completion is only supported in bash or zsh environments on Linux and macOS systems. Auto-completion covers product names, operation names, and parameter names, but does not cover parameter values.
Run the following command to enable auto-completion:
aliyun auto-completionAfter you enable auto-completion, run the following command to apply the configuration immediately, or restart the terminal:
# bash
source ~/.bash_profile
# zsh
source ~/.zshrcTo verify that auto-completion is working, type aliyun and press Tab. If a list of candidate commands appears (such as configure), auto-completion is enabled.
To disable auto-completion, run:
aliyun auto-completion --uninstallFAQs
--help shows a parameter as Optional. Can I always omit it?
Not necessarily. Some commands have mutually exclusive parameters, meaning you must specify one or the other. Such parameters are individually marked as optional, but at least one of them must be specified. Otherwise, an error is returned. For specific requirement rules, refer to the API documentation of the relevant product.