閱讀434 返回首頁    go 阿裏雲


多賬戶使用__用戶指南_命令行工具 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 賬戶下的信息

顯示如下:

multiaccout-list

最後更新:2016-11-23 16:04:06

  上一篇:go 全局參數說明__命令行結構和參數_用戶指南_命令行工具 CLI-阿裏雲
  下一篇:go 高級過濾功能__用戶指南_命令行工具 CLI-阿裏雲