跳到主要内容

配置

ecctl configure 写入资源命令使用的本地配置。它也可以读取兼容的本地 aliyun CLI 配置;当两者同时存在时,ecctl 配置会覆盖兼容配置中的同名值。

配置地域

ecctl configure set region cn-hangzhou

输出形态:

{
"key": "region",
"profile": "default",
"sensitive": false,
"value": "cn-hangzhou"
}

设置默认输出模式:

ecctl configure set output json

读取当前生效的 profile:

ecctl configure get

输出形态:

{
"lang": "",
"mode": "",
"output": "json",
"profile": "default",
"region": "cn-hangzhou"
}

凭证

设置 AccessKey 凭证:

ecctl configure set access-key-id <id>
ecctl configure set access-key-secret <secret>

使用 STS 访问时,再设置安全令牌:

ecctl configure set security-token <token>

支持的配置项

列出支持的配置项:

ecctl configure list

当前配置项:

配置项存储为取值
regionregion_id任意语法合法的阿里云地域 ID
access-key-idaccess_key_id字符串
access-key-secretaccess_key_secret字符串,敏感
security-tokensts_token字符串,敏感
langlanguageenzh-CN
outputoutput_formatjsontext

敏感值默认掩码。仅在确实需要查看本地敏感值时使用 --show-secret

Profile

--profile 写入命名 profile:

ecctl --profile production configure set output json

profile 存在后切换当前 profile:

ecctl configure use production

configure use 会在兼容的 aliyun 配置和 ecctl 配置中检查该 profile 名,然后将所选 profile 记录到 ecctl 配置文件。

全局覆盖

全局 flag 可对单条命令覆盖配置:

ecctl --region cn-beijing --output json --lang en schema --list ecs

常用全局 flag:

Flag用途
--profile选择配置 profile
--region选择当前命令的阿里云地域
--output选择 jsontext 输出
--json强制 JSON 输出
--lang选择 enzh-CN 文案
--no-color关闭人类可读输出的颜色
--agent-envelope将 JSON 输出包裹在 ecctl Agent envelope 中

环境变量

ecctl 识别以下环境变量覆盖:

变量用途
ECCTL_PROFILEALIBABACLOUD_PROFILEALIBABA_CLOUD_PROFILEALICLOUD_PROFILE未传 --profile 时的默认 profile
ECCTL_REGIONALIBABA_CLOUD_REGION_IDALIBABACLOUD_REGION_IDALICLOUD_REGION_ID未传 --region 时的地域覆盖
ALIBABA_CLOUD_CONFIG_PATHALIBABACLOUD_CONFIG_PATHALICLOUD_CONFIG_PATH兼容的 aliyun CLI 配置文件路径