开发者社区> 问答> 正文

命令行工具 CLI:多账户使用



注意:此功能适合需要管理很多账号和很多设备的用户使用。若您只需管理一个账号,请忽略此功能。
阿里云命令行工具支持多账户系统的管理操作,您可以根据需要配置多个 Access Key、Access Key Secret、Region Id 和 output format,在一个工具中管理多个不同账户的资源。关于如何配置账户,请参见 配置命令行工具(公共云版)配置命令行工具(专有云和专有域版)

基本命令结构


多账户管理的基本命令结构如下:

  1. aliyuncli configure [set/get/list] --profile profilename --key value --key1 value1

  • configure : 表示要进行配置管理。

  • set: 可选操作,表示要设置一个配置的值。

  • get: 可选操作,表示要显示一个配置的值。

  • list: 可选操作,表示要列出一个 profile 所有的值。

  • profile: 全局参数,表示当前操作中采用的 profile 是什么。具体可以参考全局参数说明中对 profile 的说明,如果不带此选项,那么表示用 default 的账户。

  • key: 配置 profile 时,具体的 key。

  • value: 跟在 key 后面,配置中的 value。


账户分类


在配置文件中,我们分为两类账户:default 账户和 profile profilename 账户。在使用命令行工具时,不带 profile 就采用 default账户,带了 profile profilename,就用 profile profilename 账户。
profile 示例如下:
  1. aliyuncli configure ← 快速配置 default 账户
  1. aliyuncli configure --profile test ← 快速配置 profile test 账户

set 示例如下:
  1. aliyuncli configure set --output table --region cn-qingdao ← 设置 default 账户, output=table, region=cn-qingdao
  1. aliyuncli configure set --output json --region cn-hangzhou --profile test1 ←设置[profile test1]账户, output = json, region = cn-hangzhou

get 示例如下:
  1. aliyuncli configure get region ← 获取 default 账户的 region 值

输出:region = cn-hangzhou
  1. aliyuncli configure get output region ← 获取 default 账户的 output 和 region 值

输出:
output = json
region = cn-hangzhou
  1. aliyuncli configure get region --profile profile1 ← 获取 profile profile1 账户下的 region 值

list 示例如下:
  1. aliyuncli configure list ← 列出 default 账户下的信息
  1. aliyuncli configure list --profile profile1 ← 列出 profile profile1 账户下的信息

显示如下:

展开
收起
行者武松 2017-10-20 15:34:09 4360 0
0 条回答
写回答
取消 提交回答
问答分类:
问答地址:
问答排行榜
最热
最新

相关电子书

更多
低代码开发师(初级)实战教程 立即下载
冬季实战营第三期:MySQL数据库进阶实战 立即下载
阿里巴巴DevOps 最佳实践手册 立即下载