alibabacloud-cli-guidance
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseAliyun CLI Expert
Aliyun CLI 专家
Guide users to manage Alibaba Cloud resources effectively using the command-line tool.
aliyunRequired permissions : see (). Extend on demand for other CLI commands.
./references/ram-policies.md## required_permissions指导用户使用命令行工具高效管理阿里云资源。
aliyun所需权限:参见(部分),其他CLI命令可按需扩展权限。
./references/ram-policies.md## required_permissionsInstructions
使用说明
User-Agent (this skill)
User-Agent(本技能)
Any invocation that calls Alibaba Cloud APIs while following this skill MUST identify the client with:
aliyunbash
export ALIBABA_CLOUD_USER_AGENT=AlibabaCloud-Agent-SkillsUse the same shell for subsequent commands, or prefix a single run: . Omit this only for steps that do not call cloud APIs (for example local browser OAuth setup before any API call). When you give the user copy-paste blocks, include this once at the top of the block (or the inline prefix on each line).
ALIBABA_CLOUD_USER_AGENT=AlibabaCloud-Agent-Skills aliyun ...aliyun configureexportaliyunExamples below assume is set whenever an command hits the API.
ALIBABA_CLOUD_USER_AGENTaliyun任何遵循本技能调用阿里云API的命令,必须将客户端标识设置为:
aliyunbash
export ALIBABA_CLOUD_USER_AGENT=AlibabaCloud-Agent-Skills后续命令需在同一shell中执行,或者单次运行时添加前缀:。只有在不调用云API的步骤中可以省略该配置(例如首次API调用前的本地浏览器OAuth设置)。当你为用户提供可复制的代码块时,请在代码块顶部一次性添加该语句(或者在每一行命令前添加内联前缀)。下面的示例默认调用API的命令都已设置。
ALIBABA_CLOUD_USER_AGENT=AlibabaCloud-Agent-Skills aliyun ...aliyun configureexportaliyunaliyunALIBABA_CLOUD_USER_AGENT1. Install and configure the CLI
1. 安装并配置CLI
If the user hasn't installed or configured the CLI, guide them through setup.
See for full details. Quick path:
./references/installation-guide.mdbash
undefined如果用户尚未安装或配置CLI,引导其完成初始化设置。完整细节参见,快速安装路径:
./references/installation-guide.mdbash
undefinedInstall or update (macOS / Linux — one command)
安装或更新(macOS / Linux 单命令执行)
/bin/bash -c "$(curl -fsSL --connect-timeout 10 --max-time 120 https://aliyuncli.alicdn.com/setup.sh)"
undefined/bin/bash -c "$(curl -fsSL --connect-timeout 10 --max-time 120 https://aliyuncli.alicdn.com/setup.sh)"
undefinedOAuth (browser login)
OAuth(浏览器登录)
When a browser can be opened on the same machine (for example a local desktop with a GUI), prefer OAuth over storing AccessKey pairs: credentials are not kept as plaintext AK/SecretKey in configuration, and sign-in can use SSO. Requires Alibaba Cloud CLI 3.0.299 or later. Not suitable for headless environments (for example SSH-only servers without a local browser).
Run interactively:
bash
aliyun configure --profile <your-profile-name> --mode OAuthFull setup (administrator consent, RAM identity assignments, vs site) is documented in Configure OAuth authentication for Alibaba Cloud CLI and .
CNINTL./references/installation-guide.mdbash
undefined当操作的设备可以打开浏览器时(例如带GUI的本地桌面设备),优先选择OAuth而非存储AccessKey对:凭证不会以明文AK/SecretKey的形式保存在配置中,且支持SSO登录。该方式要求阿里云CLI版本**≥3.0.299**,不适用于无界面环境(例如没有本地浏览器、仅支持SSH访问的服务器)。
交互式执行命令:
bash
aliyun configure --profile <your-profile-name> --mode OAuthbash
undefinedCredentials via environment variables (automation, CI/CD, headless, or when OAuth is not available)
通过环境变量配置凭证(自动化场景、CI/CD、无界面环境或无法使用OAuth时)
export ALIBABA_CLOUD_ACCESS_KEY_ID=<key-id>
export ALIBABA_CLOUD_ACCESS_KEY_SECRET=<key-secret>
export ALIBABA_CLOUD_REGION_ID=cn-hangzhou
export ALIBABA_CLOUD_ACCESS_KEY_ID=<key-id>
export ALIBABA_CLOUD_ACCESS_KEY_SECRET=<key-secret>
export ALIBABA_CLOUD_REGION_ID=cn-hangzhou
Temporary credentials (StsToken) — add:
临时凭证(StsToken)需额外添加:
export ALIBABA_CLOUD_SECURITY_TOKEN=<sts-token>
export ALIBABA_CLOUD_SECURITY_TOKEN=<sts-token>
Required when using this skill for API calls — see "User-Agent (this skill)" above
使用本技能调用API时必需配置,参见上文「User-Agent(本技能)」部分
export ALIBABA_CLOUD_USER_AGENT=AlibabaCloud-Agent-Skills
export ALIBABA_CLOUD_USER_AGENT=AlibabaCloud-Agent-Skills
Verify
验证配置
aliyun version # Should be >= 3.3.0
aliyun ecs describe-regions # Tests authentication
Aliyun CLI 3.3.0+ supports all published Alibaba Cloud product plugins.aliyun version # 版本应 ≥ 3.3.0
aliyun ecs describe-regions # 测试鉴权是否生效
Aliyun CLI 3.3.0及以上版本支持所有已发布的阿里云产品插件。Authentication modes (environment variables)
鉴权模式(环境变量)
For modes that use explicit keys or tokens (not OAuth), choose what fits the deployment context. When set, these environment variables override any values in .
~/.aliyun/config.json| Mode | When to use | Environment variables |
|---|---|---|
| AK | Development, long-lived credentials | |
| StsToken | CI/CD, temporary credentials | Same as AK, plus |
| RamRoleArn | After AssumeRole or cross-account session | Export the temporary pair from the role session: same variables as StsToken (AK + secret + |
对于使用显式密钥或令牌的模式(非OAuth),可根据部署场景选择适配的方式。环境变量配置生效后会覆盖中的所有配置值。
~/.aliyun/config.json| 模式 | 适用场景 | 环境变量 |
|---|---|---|
| AK | 开发场景、长期有效凭证 | |
| StsToken | CI/CD场景、临时凭证 | 与AK配置一致,额外添加 |
| RamRoleArn | 角色扮演AssumeRole或跨账号会话场景 | 导出自角色会话的临时凭证:变量与StsToken一致(AK + 密钥 + |
Multiple accounts or environments
多账号或多环境管理
Use separate blocks per shell session, CI job, or secret store (different / / values). For profile-based workflows backed by the config file, see .
exportALIBABA_CLOUD_ACCESS_KEY_IDALIBABA_CLOUD_ACCESS_KEY_SECRETALIBABA_CLOUD_REGION_ID./references/installation-guide.md可以为每个shell会话、CI任务或密钥存储配置独立的代码块(使用不同的 / / 值)。基于配置文件的配置流参见。
exportALIBABA_CLOUD_ACCESS_KEY_IDALIBABA_CLOUD_ACCESS_KEY_SECRETALIBABA_CLOUD_REGION_ID./references/installation-guide.md2. Consult --help
before constructing any command
--help2. 构建命令前先查阅--help
信息
--helpBuilt-in commands have inconsistent parameter naming across APIs — some use PascalCase,
others camelCase, and the exact names are not predictable. Guessing parameter names frequently
leads to errors that require multiple retries. Running first takes seconds:
--helpbash
aliyun <product> --help # Discover available subcommands
aliyun <product> <subcommand> --help # Get exact parameter names, types, structureHelp output is the authoritative source. Plugin help is especially rich — it includes type
info, structure fields, format hints, and constraints for every parameter.
When a plugin is installed, automatically shows plugin help. To view
the legacy built-in (OpenAPI-style) help instead:
aliyun <product> --helpbash
ALIBABA_CLOUD_ORIGINAL_PRODUCT_HELP=true aliyun ecs --help内置命令的参数命名在不同API之间没有统一规范,部分使用帕斯卡命名法,部分使用驼峰命名法,无法预测准确名称。猜测参数名称通常会导致错误,需要多次重试,先执行查询仅需数秒:
--helpbash
aliyun <product> --help # 查看可用的子命令
aliyun <product> <subcommand> --help # 获取准确的参数名称、类型、结构说明帮助文档是最权威的信息来源,插件的帮助信息尤其丰富,包含每个参数的类型信息、结构字段、格式提示和约束条件。
安装插件后,会自动展示插件的帮助信息,如果需要查看旧版内置(OpenAPI风格)的帮助信息,可执行:
aliyun <product> --helpbash
ALIBABA_CLOUD_ORIGINAL_PRODUCT_HELP=true aliyun ecs --help3. Ensure service plugins are available
3. 确保已安装对应服务插件
Each Alibaba Cloud product has a CLI plugin. Plugins provide consistent kebab-case commands
with comprehensive help, while the legacy built-in system has inconsistent naming and minimal
help. If you know which product to use, install the plugin directly — is
idempotent (safe to run even if already installed):
plugin installbash
aliyun plugin install --names ecs # Install (short name, case-insensitive)
aliyun plugin install --names ECS VPC RDS # Multiple at onceTo discover or verify plugins:
bash
aliyun plugin list # Installed plugins
aliyun plugin list-remote # All available plugins
aliyun plugin search <keyword> # Search by keywordPlugin names accept both short form () and full form (), case-insensitive.
ecsaliyun-cli-ecsPlugin lifecycle:
bash
aliyun plugin update --name ecs # Update a plugin
aliyun plugin uninstall --name ecs # Remove a plugin每个阿里云产品都有对应的CLI插件,插件提供统一的短横线分隔命名的命令和全面的帮助信息,而旧版内置系统命名不统一、帮助信息极少。如果明确要使用的产品,可直接安装插件,是幂等操作(即使已安装也可安全执行):
plugin installbash
aliyun plugin install --names ecs # 安装单个插件(短名称,不区分大小写)
aliyun plugin install --names ECS VPC RDS # 同时安装多个插件查询或验证插件的命令:
bash
aliyun plugin list # 已安装的插件列表
aliyun plugin list-remote # 所有可用的插件列表
aliyun plugin search <keyword> # 按关键词搜索插件插件名称支持短格式()和全格式(),不区分大小写。
ecsaliyun-cli-ecs插件生命周期管理命令:
bash
aliyun plugin update --name ecs # 更新插件
aliyun plugin uninstall --name ecs # 卸载插件4. Prefer plugin commands over built-in commands
4. 优先使用插件命令而非内置命令
The CLI has two command styles, and the subcommand casing determines which system handles it:
- All-lowercase subcommand → routed to plugin (CLI Native style)
- Contains uppercase → routed to built-in (OpenAPI style)
Plugin commands use consistent kebab-case naming for both subcommands and parameters, making
them predictable. Built-in commands use PascalCase subcommands with mixed/inconsistent parameter
naming that varies by API — you must check for every command to know the exact names.
--helpbash
undefinedCLI支持两种命令风格,子命令的大小写决定了使用哪个系统处理:
- 全小写子命令 → 路由到插件系统(CLI原生风格)
- 包含大写字母 → 路由到内置系统(OpenAPI风格)
插件命令的子命令和参数都使用统一的短横线分隔命名,可预测性强。内置命令使用帕斯卡命名的子命令,参数命名混乱且不统一,不同API之间存在差异,必须为每个命令查询才能获取准确名称。
--helpbash
undefinedPlugin (preferred): consistent kebab-case
插件命令(推荐):统一的短横线分隔命名
aliyun ecs describe-instances --biz-region-id cn-hangzhou
aliyun ecs describe-instances --biz-region-id cn-hangzhou
Built-in (fallback): PascalCase subcommand, inconsistent params
内置命令(兜底方案):帕斯卡命名子命令,参数不统一
aliyun ecs DescribeInstances --RegionId cn-hangzhou
Mixing styles causes silent failures — the CLI routes to different backends based on subcommand
casing. A kebab-case subcommand with PascalCase parameters will be sent to the plugin system,
which doesn't recognize PascalCase parameter names.
Product code is always case-insensitive (`ecs`, `Ecs`, `ECS` all work).
| Aspect | Plugin (CLI Native) | Built-in (OpenAPI) |
| ------ | ------------------- | ------------------ |
| Subcommand | `describe-instances` | `DescribeInstances` |
| Parameters | kebab-case (consistent) | Mixed (inconsistent) |
| ROA Body | Expanded to individual params | Single `--body` JSON |
| Header params | Visible in help, usable directly | Hidden, manual `--header` only |
| Help | Comprehensive with structure | Basic |aliyun ecs DescribeInstances --RegionId cn-hangzhou
混合使用两种风格会导致静默失败,CLI会根据子命令的大小写路由到不同的后端。短横线命名的子命令搭配帕斯卡命名的参数会被发送到插件系统,而插件系统无法识别帕斯卡命名的参数。
产品代码始终不区分大小写(`ecs`、`Ecs`、`ECS`均生效)。
| 对比项 | 插件命令(CLI原生) | 内置命令(OpenAPI) |
| ------ | ------------------- | ------------------ |
| 子命令 | `describe-instances` | `DescribeInstances` |
| 参数 | 短横线分隔命名(统一) | 混合命名(不统一) |
| ROA Body | 展开为独立参数 | 单个`--body`JSON参数 |
| Header参数 | 帮助信息可见,可直接使用 | 隐藏,仅支持手动添加`--header` |
| 帮助信息 | 结构完整、内容全面 | 基础信息 |5. Understand global vs business parameter naming
5. 区分全局参数和业务参数命名
The CLI plugin system reserves certain global parameters for its own use:
- /
--region-id— controls which API endpoint the request is sent to (e.g.--region). This is a routing concern, not a business field.ecs.cn-hangzhou.aliyuncs.com - Other globals include ,
--profile,--api-version, etc.--output
Many APIs also define their own or parameter in the API spec — these are
business parameters with API-specific meaning (e.g. "the region to create this resource in").
The global and the API's serve different purposes, but they would
collide on the command line.
RegionIdRegion--region-idRegionIdThe plugin system resolves this automatically during code generation:
- prefix (default): the API parameter
--biz-becomesRegionId--biz-region-id - prefix (fallback): if
--<product>-is already taken by another parameter, the plugin falls back to--biz-region-id(e.g.--<product>-region-id)--ecs-region-id
This means in plugin commands, is always the global endpoint selector, and
the business region is (or ). Using where
you meant the business parameter silently changes the endpoint without setting the intended field.
--region-id--biz-region-id--<product>-region-id--region-idAlways check to see the actual parameter name — it is the authoritative source for
whether a given command uses , , or something else.
--help--biz-region-id--<product>-region-idCLI插件系统预留了部分全局参数供自身使用:
- /
--region-id— 控制请求发送到的API端点(例如--region),属于路由配置,不是业务字段。ecs.cn-hangzhou.aliyuncs.com - 其他全局参数包括、
--profile、--api-version等。--output
很多API也会在接口定义中声明自己的或参数,这些是业务参数,具有API特定的含义(例如「创建资源的所属地域」)。全局和API的用途不同,但在命令行中会产生命名冲突。
RegionIdRegion--region-idRegionId插件系统在代码生成阶段会自动解决该冲突:
- 默认添加前缀:API参数
--biz-会变为RegionId--biz-region-id - 兜底添加前缀:如果
--<product>-已经被其他参数占用,插件会使用--biz-region-id格式(例如--<product>-region-id)--ecs-region-id
这意味着在插件命令中,始终是全局端点选择参数,业务地域参数为(或)。如果本该使用业务参数的地方误用了,会静默修改请求端点,而不会设置预期的业务字段。
--region-id--biz-region-id--<product>-region-id--region-id请始终通过查询实际的参数名称,它是确定命令使用、还是其他名称的权威依据。
--help--biz-region-id--<product>-region-id6. Use structured parameter syntax
6. 使用结构化参数语法
Plugins support structured input that the framework serializes automatically. This avoids
the error-prone legacy / syntax.
--Tag.N.Key--Param.N=valuePrimitives and lists:
bash
--instance-id i-abc123 # single value
--security-group-ids sg-001 sg-002 sg-003 # space-separated list
--instance-id i-abc --instance-id i-def # repeated param (also valid)Key-value objects and repeatable structures:
bash
--tag Key=env Value=prod --tag Key=app Value=web # repeatable key-value
--capacity-options OnDemandBaseCapacity=12 CompensateWithOnDemand=true # object
--data-disk '{"DiskName":"d1","Size":100}' # complex structure (JSON)Check for each command — it shows the exact type, structure fields, and whether a
parameter is repeatable.
--help插件支持结构化输入,框架会自动序列化,避免使用容易出错的旧版 / 语法。
--Tag.N.Key--Param.N=value基础类型和列表:
bash
--instance-id i-abc123 # 单个值
--security-group-ids sg-001 sg-002 sg-003 # 空格分隔的列表
--instance-id i-abc --instance-id i-def # 重复参数(同样生效)键值对象和可重复结构:
bash
--tag Key=env Value=prod --tag Key=app Value=web # 可重复键值对
--capacity-options OnDemandBaseCapacity=12 CompensateWithOnDemand=true # 对象
--data-disk '{"DiskName":"d1","Size":100}' # 复杂结构(JSON格式)请为每个命令查询,它会展示准确的类型、结构字段,以及参数是否可重复。
--help7. OSS uses custom commands
7. OSS使用自定义命令
Unlike other products, OSS has a hand-written implementation with custom command syntax.
API-style commands like or do not exist for OSS — using them will fail
silently or produce confusing errors. Always check help first:
PutBucketGetObjectbash
aliyun oss --help # Basic operations (cp, ls, mb, rm, etc.)
aliyun ossutil --help # Advanced utilities (sync, stat, etc.)The lines below are syntax examples only ( placeholders). Do not run them verbatim — substitute real paths, bucket names, and file names before executing.
<your-*>bash
aliyun oss cp <your-file-name>.txt oss://<your-bucket-name>/ # Upload
aliyun oss mb oss://<your-bucket-name> # Create bucket
aliyun ossutil sync ./<your-folder-name>/ oss://<your-bucket-name>/ # Sync directory与其他产品不同,OSS使用定制化实现,有专属的命令语法,不存在或这类API风格的命令,使用这类命令会静默失败或产生难以理解的错误,请始终先查询帮助信息:
PutBucketGetObjectbash
aliyun oss --help # 基础操作(cp、ls、mb、rm等)
aliyun ossutil --help # 高级工具(sync、stat等)下面的命令仅为语法示例(为占位符),不要直接执行,执行前请替换为真实的路径、桶名称和文件名。
<your-*>bash
aliyun oss cp <your-file-name>.txt oss://<your-bucket-name>/ # 上传文件
aliyun oss mb oss://<your-bucket-name> # 创建存储桶
aliyun ossutil sync ./<your-folder-name>/ oss://<your-bucket-name>/ # 同步目录8. Filter and format output
8. 过滤和格式化输出
Use (JMESPath) to extract specific fields from API responses, and
to control the format. This avoids piping large JSON blobs through external tools:
--cli-query--outputbash
undefined使用(JMESPath)从API响应中提取特定字段,使用控制输出格式,避免通过外部工具处理大量JSON数据:
--cli-query--outputbash
undefinedJMESPath filter: only running instances, selected fields
JMESPath过滤器:仅查询运行中实例的指定字段
aliyun ecs describe-instances
--biz-region-id cn-hangzhou
--cli-query "Instances.Instance[?Status=='Running'].{ID:InstanceId,Name:InstanceName}"
--biz-region-id cn-hangzhou
--cli-query "Instances.Instance[?Status=='Running'].{ID:InstanceId,Name:InstanceName}"
aliyun ecs describe-instances
--biz-region-id cn-hangzhou
--cli-query "Instances.Instance[?Status=='Running'].{ID:InstanceId,Name:InstanceName}"
--biz-region-id cn-hangzhou
--cli-query "Instances.Instance[?Status=='Running'].{ID:InstanceId,Name:InstanceName}"
Output formats
输出格式
aliyun ecs describe-instances --biz-region-id cn-hangzhou --output json # default
aliyun ecs describe-instances --biz-region-id cn-hangzhou --output table # human-readable table
aliyun ecs describe-instances --biz-region-id cn-hangzhou --output cols=InstanceId,InstanceName,Status rows="Instances.Instance[]" # custom columns
undefinedaliyun ecs describe-instances --biz-region-id cn-hangzhou --output json # 默认格式
aliyun ecs describe-instances --biz-region-id cn-hangzhou --output table # 易读表格格式
aliyun ecs describe-instances --biz-region-id cn-hangzhou --output cols=InstanceId,InstanceName,Status rows="Instances.Instance[]" # 自定义列
undefined9. Pagination
9. 分页
Many list commands return paginated results. Use and to control:
--page-number--page-sizebash
aliyun ecs describe-instances \
--biz-region-id cn-hangzhou \
--page-number 1 \
--page-size 50To fetch all pages automatically without manual loops, use :
--pagerbash
aliyun ecs describe-instances \
--biz-region-id cn-hangzhou \
--pager path='Instances.Instance[]' PageNumber=PageNumber PageSize=PageSizeThe argument specifies which JSON field contains the page data to merge.
path很多列表命令返回分页结果,可使用和控制分页:
--page-number--page-sizebash
aliyun ecs describe-instances \
--biz-region-id cn-hangzhou \
--page-number 1 \
--page-size 50如果需要自动获取所有分页结果无需手动循环,可使用:
--pagerbash
aliyun ecs describe-instances \
--biz-region-id cn-hangzhou \
--pager path='Instances.Instance[]' PageNumber=PageNumber PageSize=PageSizepath10. Wait for resource state
10. 等待资源状态变更
Some commands support built-in waiters for automation — poll until a resource reaches the desired state:
bash
aliyun vpc describe-vpc-attribute \
--biz-region-id cn-shanghai \
--vpc-id <your-vpc-id> \
--waiter expr='Status' to='Available'部分命令支持内置的等待器,可用于自动化场景,轮询直到资源达到预期状态:
bash
aliyun vpc describe-vpc-attribute \
--biz-region-id cn-shanghai \
--vpc-id <your-vpc-id> \
--waiter expr='Status' to='Available'11. Debugging
11. 调试
When troubleshooting command failures, these flags reveal what's happening under the hood — the full HTTP request/response and parameter validation details:
- — detailed request/response logs (shows endpoint, serialized params, response)
--log-level debug - — validate command without executing (checks parameter parsing)
--cli-dry-run - — environment variable to set log level globally
ALIBABA_CLOUD_CLI_LOG_CONFIG=debug
For 403, Forbidden, NoPermission, or other RAM-style denials, the identity behind the credentials lacks permission for the underlying API action. See for the skill’s table, on-demand authorization, and how to narrow permissions.
./references/ram-policies.mdrequired_permissions排查命令失败问题时,以下参数可以展示底层执行细节:完整的HTTP请求/响应和参数校验详情:
- — 详细的请求/响应日志(展示端点、序列化参数、响应内容)
--log-level debug - — 仅校验命令不执行(检查参数解析是否正确)
--cli-dry-run - — 全局设置日志级别的环境变量
ALIBABA_CLOUD_CLI_LOG_CONFIG=debug
如果遇到403、Forbidden、NoPermission或其他RAM类拒绝错误,说明凭证对应的身份缺少底层API操作的权限。参见查看本技能的表、按需授权方式和权限最小化配置方法。
./references/ram-policies.mdrequired_permissions12. Multi-version API support
12. 多版本API支持
Some products (e.g. ESS, SLB) ship multiple API versions with different command sets and
capabilities. Using the wrong version may cause missing parameters, deprecated behavior, or
entirely different command availability. Not all products have multiple versions — if
returns an error, the product is single-version and no action is needed.
list-api-versions部分产品(例如ESS、SLB)提供多个API版本,不同版本的命令集和能力不同。使用错误的版本可能导致参数缺失、行为废弃,甚至完全找不到可用命令。并非所有产品都有多个版本,如果返回错误,说明该产品只有单一版本,无需额外操作。
list-api-versionsDiscover versions
查询版本
bash
aliyun <product> list-api-versionsExample output (ESS):
text
Product: ESS
Supported API versions:
* 2014-08-28 (default)
2016-07-22
2022-02-22The marks the default version. Each version may expose a different set of commands — newer
versions often add commands or change parameter names.
*bash
aliyun <product> list-api-versions示例输出(ESS):
text
Product: ESS
Supported API versions:
* 2014-08-28 (default)
2016-07-22
2022-02-22*Specify version per command
单命令指定版本
bash
aliyun ess describe-scaling-groups --api-version 2022-02-22 --biz-region-id cn-hangzhoubash
aliyun ess describe-scaling-groups --api-version 2022-02-22 --biz-region-id cn-hangzhouSet a default version via environment variable
通过环境变量设置默认版本
To avoid passing on every call, set the default for a product:
--api-versionbash
export ALIBABA_CLOUD_ESS_API_VERSION=2022-02-22
export ALIBABA_CLOUD_SLB_API_VERSION=2014-05-15The pattern is (product code in uppercase).
This is especially useful in scripts or CI/CD where you want consistent version behavior
across multiple commands.
ALIBABA_CLOUD_<PRODUCT_CODE>_API_VERSION为了避免每次调用都添加,可为产品设置默认版本:
--api-versionbash
export ALIBABA_CLOUD_ESS_API_VERSION=2022-02-22
export ALIBABA_CLOUD_SLB_API_VERSION=2014-05-15命名规则为(产品代码为大写)。该方式特别适合脚本或CI/CD场景,可保证多个命令使用一致的版本行为。
ALIBABA_CLOUD_<PRODUCT_CODE>_API_VERSIONView commands for a specific version
查看指定版本的命令
Different API versions may have different command sets. To see what's available:
bash
aliyun ess --api-version 2022-02-22 # List commands in this version
aliyun ess <cmd> --api-version 2022-02-22 --help # Help for a specific command in this version不同API版本可能有不同的命令集,查询可用命令的方式:
bash
aliyun ess --api-version 2022-02-22 # 列出该版本的所有命令
aliyun ess <cmd> --api-version 2022-02-22 --help # 查询该版本下指定命令的帮助信息When to specify version
何时需要指定版本
- Default version works for most cases — only specify when you need features from a newer version
- Check output — if a parameter you expect is missing, it may exist in a different version
--help - Pinning versions in scripts — use the environment variable to ensure reproducible behavior
- 默认版本适配绝大多数场景 — 仅当需要使用新版本的特性时才需要指定版本
- 检查输出 — 如果找不到预期的参数,可能存在于其他版本中
--help - 脚本中固定版本 — 使用环境变量保证行为可复现
Global Flags Reference
全局参数参考
These flags are available on all plugin commands:
| Flag | Purpose |
|---|---|
| API endpoint region (global, not business region) |
| Use a named credential profile |
| Override API version for this command |
| Response format |
| JMESPath filter on response |
| Verbose request/response logging |
| Validate without executing |
| Override service endpoint |
| Retry count for failed requests |
| Suppress output |
| Auto-merge all pages for pageable APIs |
所有插件命令都支持以下参数:
| 参数 | 用途 |
|---|---|
| API端点地域(全局参数,非业务地域) |
| 使用指定名称的凭证配置 |
| 覆盖当前命令的API版本 |
| 响应格式 |
| 对响应执行JMESPath过滤 |
| 输出详细的请求/响应日志 |
| 仅校验不执行命令 |
| 覆盖服务端点 |
| 请求失败重试次数 |
| 关闭输出 |
| 为分页API自动合并所有分页结果 |
Common Workflows
常用工作流
ECS Instances
ECS实例管理
bash
aliyun plugin list | grep ecsbash
aliyun plugin list | grep ecsIf missing: aliyun plugin install --names ecs
如果未安装:aliyun plugin install --names ecs
aliyun ecs describe-instances --biz-region-id cn-hangzhou
The `create-instance` example below **provisions billable resources** (fixed image ID, instance type, and disk as illustration). **Do not run it verbatim** — adjust region, image, type, disks, network, and tags for your account and policies before executing.
```bash
aliyun ecs create-instance \
--biz-region-id cn-hangzhou \
--instance-type ecs.g7.large \
--image-id ubuntu_20_04_arm64_20G_alibase_20250625.vhd \
--data-disk Category=cloud_essd Size=100 \
--tag Key=env Value=prod --tag Key=app Value=webaliyun ecs describe-instances --biz-region-id cn-hangzhou
下面的`create-instance`示例**会创建付费资源**(使用固定的镜像ID、实例规格和磁盘作为示例)。**不要直接执行**,执行前请根据你的账号和策略调整地域、镜像、规格、磁盘、网络和标签。
```bash
aliyun ecs create-instance \
--biz-region-id cn-hangzhou \
--instance-type ecs.g7.large \
--image-id ubuntu_20_04_arm64_20G_alibase_20250625.vhd \
--data-disk Category=cloud_essd Size=100 \
--tag Key=env Value=prod --tag Key=app Value=webFunction Compute (ROA Body Expansion)
函数计算(ROA Body展开)
bash
aliyun plugin list | grep fcbash
aliyun plugin list | grep fcIf missing: aliyun plugin install --names fc
如果未安装:aliyun plugin install --names fc
The block below is a **syntax example** (`<your-function-name>` and other values are illustrative). **Do not run verbatim** — set the real function name, runtime, handler, memory, timeout, and add any required VPC or service role settings for your environment. Plugin commands expand ROA body fields into individual params (no `--body` JSON needed).
```bash
aliyun fc create-function \
--function-name <your-function-name> \
--runtime python3.9 \
--handler index.handler \
--memory-size 512 \
--timeout 60 \
--description "Process uploaded images"
下面的代码块是**语法示例**(`<your-function-name>`和其他值仅为示例)。**不要直接执行**,请设置真实的函数名称、运行时、处理程序、内存、超时时间,并根据你的环境添加所需的VPC或服务角色配置。插件命令会将ROA Body字段展开为独立参数(无需使用`--body`JSON参数)。
```bash
aliyun fc create-function \
--function-name <your-function-name> \
--runtime python3.9 \
--handler index.handler \
--memory-size 512 \
--timeout 60 \
--description "Process uploaded images"Multi-Version API (ESS)
多版本API(ESS)
bash
undefinedbash
undefinedCheck available versions
查看可用版本
aliyun ess list-api-versions
aliyun ess list-api-versions
Use the latest version for new features
使用最新版本获取新特性
export ALIBABA_CLOUD_ESS_API_VERSION=2022-02-22
aliyun ess describe-scaling-groups --biz-region-id cn-hangzhou
export ALIBABA_CLOUD_ESS_API_VERSION=2022-02-22
aliyun ess describe-scaling-groups --biz-region-id cn-hangzhou
Or specify per command without env var
或者不使用环境变量,单命令指定版本
aliyun ess describe-scaling-groups --api-version 2022-02-22 --biz-region-id cn-hangzhou
undefinedaliyun ess describe-scaling-groups --api-version 2022-02-22 --biz-region-id cn-hangzhou
undefinedResponse Format
响应格式
When providing CLI commands:
- Explain what the command does and why specific parameters are used
- Show the complete command with all required parameters
- Call out non-obvious values — especially prefixed parameters and their reason
--biz- - Suggest when the user is troubleshooting
--log-level debug - For API calls, ensure is set in the same shell or inlined before
ALIBABA_CLOUD_USER_AGENT=AlibabaCloud-Agent-Skills(see User-Agent (this skill))aliyun
提供CLI命令时遵循以下规则:
- 解释命令的用途,以及使用特定参数的原因
- 展示包含所有必填参数的完整命令
- 标注不直观的参数值 — 尤其是前缀的参数及其使用原因
--biz- - 用户排查问题时建议添加参数
--log-level debug - 对于API调用,确保在同一shell中设置了,或者在
ALIBABA_CLOUD_USER_AGENT=AlibabaCloud-Agent-Skills命令前添加内联前缀(参见**User-Agent(本技能)**部分)aliyun
References
参考文档
- — Installation, configuration modes, credential setup
./references/installation-guide.md - — Complete command syntax guide
./references/command-syntax.md - — Global flags reference
./references/global-flags.md - — On-demand RAM, least privilege, common permission errors
./references/ram-policies.md
- — 安装、配置模式、凭证设置
./references/installation-guide.md - — 完整命令语法指南
./references/command-syntax.md - — 全局参数参考
./references/global-flags.md - — 按需RAM配置、最小权限、常见权限错误
./references/ram-policies.md