aliyun-cli-manage

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese
Category: tool
分类:工具

Alibaba Cloud Generic CLI (aliyun) Skill

阿里云通用CLI(aliyun)技能

Validation

验证

bash
mkdir -p output/aliyun-cli-manage
python skills/platform/cli/aliyun-cli-manage/scripts/ensure_aliyun_cli.py --help > output/aliyun-cli-manage/validate-help.txt
Pass criteria: command exits 0 and
output/aliyun-cli-manage/validate-help.txt
is generated.
bash
mkdir -p output/aliyun-cli-manage
python skills/platform/cli/aliyun-cli-manage/scripts/ensure_aliyun_cli.py --help > output/aliyun-cli-manage/validate-help.txt
通过标准:命令退出码为0,且生成
output/aliyun-cli-manage/validate-help.txt
文件。

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.
  • 将CLI版本检查、API输出和错误日志保存在
    output/aliyun-cli-manage/
    目录下。
  • 针对每个变更操作,留存请求参数和结果摘要。

Goals

目标

  • Use official
    aliyun
    CLI to execute Alibaba Cloud OpenAPI operations.
  • Provide a standard flow for install, configuration, API discovery, execution, and troubleshooting.
  • 使用官方
    aliyun
    CLI执行阿里云OpenAPI操作。
  • 提供安装、配置、API发现、执行和问题排查的标准流程。

Quick Flow

快速流程

  1. Run the version guard script first (check first, then decide whether to upgrade).
  2. If not installed or check interval reached, the script downloads and installs the latest official package.
  3. Configure credentials and default region (recommend
    default
    profile).
  4. Use
    aliyun <product> --help
    /
    aliyun <product> <ApiName> --help
    to confirm parameters.
  5. Run read-only queries first, then mutating operations.
  1. 首先运行版本防护脚本(先检查,再决定是否升级)。
  2. 如果未安装或达到检查间隔,脚本会下载并安装最新的官方包。
  3. 配置凭证和默认地域(推荐使用
    default
    配置文件)。
  4. 使用
    aliyun <product> --help
    /
    aliyun <product> <ApiName> --help
    确认参数。
  5. 先运行只读查询,再执行变更操作。

Version Guard (Practical)

版本防护(实用说明)

Prefer the bundled script to avoid unnecessary downloads on every run:
bash
python skills/platform/cli/aliyun-cli-manage/scripts/ensure_aliyun_cli.py
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.
  • ALIYUN_CLI_FORCE_UPDATE=1
    :force update (ignore interval).
  • ALIYUN_CLI_MIN_VERSION=3.2.9
    :minimum acceptable version.
  • ALIYUN_CLI_INSTALL_DIR=~/.local/bin
    :installation directory.
Manual parameter examples:
bash
python skills/platform/cli/aliyun-cli-manage/scripts/ensure_aliyun_cli.py \
  --interval-hours 24 \
  --min-version 3.2.9
优先使用捆绑脚本,避免每次运行时不必要的下载:
bash
python skills/platform/cli/aliyun-cli-manage/scripts/ensure_aliyun_cli.py
默认行为:
  • 检查间隔:24小时(可通过环境变量配置)。
  • 在间隔内且版本满足要求:跳过下载。
  • 超出间隔/未安装/低于最低版本:自动下载并安装最新官方包。
可选控制项(环境变量):
  • ALIYUN_CLI_CHECK_INTERVAL_HOURS=24
    :检查间隔。
  • ALIYUN_CLI_FORCE_UPDATE=1
    :强制更新(忽略间隔)。
  • ALIYUN_CLI_MIN_VERSION=3.2.9
    :可接受的最低版本。
  • ALIYUN_CLI_INSTALL_DIR=~/.local/bin
    :安装目录。
手动参数示例:
bash
python skills/platform/cli/aliyun-cli-manage/scripts/ensure_aliyun_cli.py \
  --interval-hours 24 \
  --min-version 3.2.9

Install (Linux example)

安装(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
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

Configure Credentials

配置凭证

bash
aliyun configure set \
  --profile default \
  --mode AK \
  --access-key-id <AK> \
  --access-key-secret <SK> \
  --region cn-hangzhou
View configured profiles:
bash
aliyun configure list
bash
aliyun configure set \
  --profile default \
  --mode AK \
  --access-key-id <AK> \
  --access-key-secret <SK> \
  --region cn-hangzhou
查看已配置的配置文件:
bash
aliyun configure list

Command structure

命令结构

  • Generic form:
    aliyun <product> <ApiName> --Param1 value1 --Param2 value2
  • REST form:
    aliyun <product> [GET|POST|PUT|DELETE] <PathPattern> --body '...json...'
  • 通用格式:
    aliyun <product> <ApiName> --Param1 value1 --Param2 value2
  • REST格式:
    aliyun <product> [GET|POST|PUT|DELETE] <PathPattern> --body '...json...'

API Discovery and Parameter Validation

API发现与参数校验

bash
aliyun help
aliyun ecs --help
aliyun ecs DescribeRegions --help
bash
aliyun help
aliyun ecs --help
aliyun ecs DescribeRegions --help

Common Read-Only Examples

常用只读操作示例

bash
undefined
bash
undefined

ECS: list regions

ECS: 列出地域

aliyun ecs DescribeRegions
aliyun ecs DescribeRegions

ECS: list instances by region

ECS: 按地域列出实例

aliyun ecs DescribeInstances --RegionId cn-hangzhou
aliyun ecs DescribeInstances --RegionId cn-hangzhou

SLS: list projects by endpoint

SLS: 按端点列出项目

aliyun sls ListProject --endpoint cn-hangzhou.log.aliyuncs.com --size 100
undefined
aliyun sls ListProject --endpoint cn-hangzhou.log.aliyuncs.com --size 100
undefined

Common Issues

常见问题

  • InvalidAccessKeyId.NotFound
    /
    SignatureDoesNotMatch
    :check AK/SK and profile.
  • MissingRegionId
    :add
    --region
    or configure default region in profile.
  • for SLS endpoint errors, explicitly pass
    --endpoint <region>.log.aliyuncs.com
    .
  • InvalidAccessKeyId.NotFound
    /
    SignatureDoesNotMatch
    :检查AK/SK和配置文件。
  • MissingRegionId
    :添加
    --region
    参数,或在配置文件中设置默认地域。
  • 若出现SLS端点错误,显式传入
    --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.
  • 启动任务前先运行
    ensure_aliyun_cli.py
  • 如果资源范围不明确,先查询再执行变更。
  • 在执行删除/覆盖操作前,先输出目标资源列表。
  • 批量操作时,先在小范围内验证单个操作项。

References

参考资料

  • Official source list:
    references/sources.md
  • 官方来源列表:
    references/sources.md

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.
  • 执行前配置最小权限的阿里云凭证。
  • 优先使用环境变量:
    ALICLOUD_ACCESS_KEY_ID
    ALICLOUD_ACCESS_KEY_SECRET
    ,可选配置
    ALICLOUD_REGION_ID
  • 如果地域不明确,执行变更操作前先询问用户。

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.
  1. 确认用户意图、地域、标识符,以及操作是只读还是变更类型。
  2. 先执行一个最小化的只读查询,验证连通性和权限。
  3. 传入显式参数并限定范围,执行目标操作。
  4. 验证结果并保存输出/凭证文件。