Category: tool
Alibaba Cloud Generic CLI (aliyun) Skill
Validation
CODEBLOCK0
Pass criteria: command exits 0 and output/aliyun-cli-manage/validate-help.txt is generated.
Output And Evidence
- - Save CLI version checks, API outputs, and error logs under
output/aliyun-cli-manage/. - For each mutating action, keep request parameters and result summaries.
Goals
- - Use official
aliyun CLI to execute Alibaba Cloud OpenAPI operations. - Provide a standard flow for install, configuration, API discovery, execution, and troubleshooting.
Quick Flow
- 1. Run the version guard script first (check first, then decide whether to upgrade).
- If not installed or check interval reached, the script downloads and installs the latest official package.
- Configure credentials and default region (recommend
default profile). - Use
aliyun <product> --help / aliyun <product> <ApiName> --help to confirm parameters. - Run read-only queries first, then mutating operations.
Version Guard (Practical)
Prefer the bundled script to avoid unnecessary downloads on every run:
CODEBLOCK1
Default behavior:
- - Check interval: 24 hours (configurable via environment variable).
- Within interval and version is sufficient: skip download.
- Exceeded interval / not installed / below minimum version: auto-download and install latest official package.
Optional controls (environment variables):
- -
ALIYUN_CLI_CHECK_INTERVAL_HOURS=24:check interval. - INLINECODE7 :force update (ignore interval).
- INLINECODE8 :minimum acceptable version.
- INLINECODE9 :installation directory.
Manual parameter examples:
CODEBLOCK2
Install (Linux example)
CODEBLOCK3
Configure Credentials
CODEBLOCK4
View configured profiles:
CODEBLOCK5
Command structure
- - Generic form: INLINECODE10
- REST form: INLINECODE11
API Discovery and Parameter Validation
CODEBLOCK6
Common Read-Only Examples
CODEBLOCK7
Common Issues
- -
InvalidAccessKeyId.NotFound / SignatureDoesNotMatch:check AK/SK and profile. - INLINECODE14 :add
--region or configure default region in profile. - for SLS endpoint errors, explicitly pass
--endpoint <region>.log.aliyuncs.com.
Execution Recommendations
- - Run
ensure_aliyun_cli.py before starting tasks. - If resource scope is unclear, query first then mutate.
- Before delete/overwrite operations, output the target resource list first.
- For batch operations, validate one item in a small scope first.
References
- - Official source list: INLINECODE18
Prerequisites
- - Configure least-privilege Alibaba Cloud credentials before execution.
- Prefer environment variables:
ALICLOUD_ACCESS_KEY_ID, ALICLOUD_ACCESS_KEY_SECRET, optional ALICLOUD_REGION_ID. - If region is unclear, ask the user before running mutating operations.
Workflow
1) Confirm user intent, region, identifiers, and whether the operation is read-only or mutating.
2) Run one minimal read-only query first to verify connectivity and permissions.
3) Execute the target operation with explicit parameters and bounded scope.
4) Verify results and save output/evidence files.
技能名称: aliyun-cli-manage
详细描述:
类别: 工具
阿里云通用CLI(aliyun)技能
验证
bash
mkdir -p output/aliyun-cli-manage
python skills/platform/cli/aliyun-cli-manage/scripts/ensurealiyuncli.py --help > output/aliyun-cli-manage/validate-help.txt
通过标准:命令退出码为0,且生成了 output/aliyun-cli-manage/validate-help.txt 文件。
输出与证据
- - 将CLI版本检查、API输出和错误日志保存在 output/aliyun-cli-manage/ 目录下。
- 对于每个变更操作,保留请求参数和结果摘要。
目标
- - 使用官方 aliyun CLI执行阿里云OpenAPI操作。
- 提供安装、配置、API发现、执行和故障排除的标准流程。
快速流程
- 1. 首先运行版本保护脚本(先检查,再决定是否升级)。
- 如果未安装或检查间隔已到,脚本将下载并安装最新的官方包。
- 配置凭证和默认区域(推荐使用 default 配置文件)。
- 使用 aliyun <产品> --help / aliyun <产品> --help 确认参数。
- 先执行只读查询,再执行变更操作。
版本保护(实用)
优先使用内置脚本,避免每次运行时进行不必要的下载:
bash
python skills/platform/cli/aliyun-cli-manage/scripts/ensurealiyuncli.py
默认行为:
- - 检查间隔:24小时(可通过环境变量配置)。
- 在间隔内且版本足够:跳过下载。
- 超过间隔/未安装/低于最低版本:自动下载并安装最新的官方包。
可选控制(环境变量):
- - ALIYUNCLICHECKINTERVALHOURS=24:检查间隔。
- ALIYUNCLIFORCEUPDATE=1:强制更新(忽略间隔)。
- ALIYUNCLIMINVERSION=3.2.9:可接受的最低版本。
- ALIYUNCLIINSTALL_DIR=~/.local/bin:安装目录。
手动参数示例:
bash
python skills/platform/cli/aliyun-cli-manage/scripts/ensurealiyuncli.py \
--interval-hours 24 \
--min-version 3.2.9
安装(Linux示例)
bash
curl -fsSL https://aliyuncli.alicdn.com/aliyun-cli-linux-latest-amd64.tgz -o /tmp/aliyun-cli.tgz
mkdir -p ~/.local/bin
tar -xzf /tmp/aliyun-cli.tgz -C /tmp
mv /tmp/aliyun ~/.local/bin/aliyun
chmod +x ~/.local/bin/aliyun
~/.local/bin/aliyun version
配置凭证
bash
aliyun configure set \
--profile default \
--mode AK \
--access-key-id \
--access-key-secret \
--region cn-hangzhou
查看已配置的配置文件:
bash
aliyun configure list
命令结构
- - 通用形式:aliyun <产品> --参数1 值1 --参数2 值2
- REST形式:aliyun <产品> [GET|POST|PUT|DELETE] <路径模式> --body ...json...
API发现与参数验证
bash
aliyun help
aliyun ecs --help
aliyun ecs DescribeRegions --help
常见只读示例
bash
ECS:列出区域
aliyun ecs DescribeRegions
ECS:按区域列出实例
aliyun ecs DescribeInstances --RegionId cn-hangzhou
SLS:按端点列出项目
aliyun sls ListProject --endpoint cn-hangzhou.log.aliyuncs.com --size 100
常见问题
- - InvalidAccessKeyId.NotFound / SignatureDoesNotMatch:检查AK/SK和配置文件。
- MissingRegionId:添加 --region 或在配置文件中配置默认区域。
- 对于SLS端点错误,显式传递 --endpoint <区域>.log.aliyuncs.com。
执行建议
- - 在开始任务前运行 ensurealiyuncli.py。
- 如果资源范围不明确,先查询再变更。
- 在删除/覆盖操作前,先输出目标资源列表。
- 对于批量操作,先在小范围内验证一个项目。
参考
- - 官方来源列表:references/sources.md
前置条件
- - 执行前配置最小权限的阿里云凭证。
- 优先使用环境变量:ALICLOUDACCESSKEYID、ALICLOUDACCESSKEYSECRET,可选 ALICLOUDREGIONID。
- 如果区域不明确,在执行变更操作前询问用户。
工作流程
1) 确认用户意图、区域、标识符,以及操作是只读还是变更。
2) 先运行一个最小的只读查询,验证连接性和权限。
3) 使用明确的参数和有限的范围执行目标操作。
4) 验证结果并保存输出/证据文件。