• Stars
    star
    770
  • Rank 59,000 (Top 2 %)
  • Language
    Go
  • License
    Apache License 2.0
  • Created over 9 years ago
  • Updated about 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Alibaba Cloud CLI

English | 简体中文

Alibaba Cloud CLI

Go build Status Appveyor Build Status codecov License Go Report
Latest Stable Version GitHub Release Date
GitHub All Releases

The Alibaba Cloud CLI is an open source tool, you can get the latest version from GitHub. You can also try it out in the Cloud Shell before installing the CLI.

Introduction

The Alibaba Cloud CLI is a tool to manage and use Alibaba Cloud resources through a command line interface. It is written in Go and built on the top of Alibaba Cloud OpenAPI.

Note: Alibaba Cloud CLI access the Alibaba Cloud services through OpenAPI. Before using Alibaba Cloud CLI, make sure that you have activated the service to use and known how to use OpenAPI.

Troubleshoot

Troubleshoot Provide OpenAPI diagnosis service to help developers locate quickly and provide solutions for developers through RequestID or error message.

CLI Releases

The release notes for the CLI can be found in the CHANGELOG

Installation

  • Download installer (Recommended)

    Download the installer, then extract the installer. You can move the extracted aliyun executable file to the /usr/local/bin directory or add it to the $PATH.

    Download link: (Latest Stable Version)

    All releases please click here.

  • Use brew If you have installed brew in your computer, you can use it to install Alibaba Cloud CLI as following:

brew install aliyun-cli

If you need detailed installation steps or compile the installation steps, please visit Installation Guide.

Configure

For detailed configuration instructions, please visit the official website Configuration Alibaba Cloud CLI.

Before using Alibaba Cloud CLI to invoke the services, you need to configure the credential information, region, language, etc.

You can run the aliyun configure command for quick configuration.

$ aliyun configure
Configuring profile 'default' ...
Aliyun Access Key ID [None]: <Your AccessKey ID>
Aliyun Access Key Secret [None]: <Your AccessKey Secret>
Default Region Id [None]: cn-hangzhou
Default output format [json]: json
Default Language [zh]: zh

Configure authentication methods

You can specify the authentication method to use by using the configure command with the --mode <authenticationMethod> option.

The following are supported authentication methods:

Authentication methods Description
AK Use AccessKey ID and Secret to access Alibaba Cloud services
StsToken Use STS token to access Alibaba Cloud services
RamRoleArn Use the AssumeRole to access Alibaba Cloud services
EcsRamRole Use the EcsRamRole to access ECS resources

Use an external program to get credentials

You can use --mode External to specify to obtain credential data through an external program, and CLI will execute the program command and return it as a credential to initiate the call.

Agreement:

  1. The output location of the external program is standard output.
  2. The output format is json string.
  3. The output contains the key fields required by the CLI and credential fields

Key field:

  • mode: Specify the type of credentials returned

Example of the return of each credential type:

  • AK
{
  "mode": "AK",
  "access_key_id": "accessKeyId",
  "access_key_secret": "accessKeySecret"
}
  • StsToken
{
  "mode": "StsToken",
  "access_key_id": "accessKeyId",
  "access_key_secret": "accessKeySecret",
  "sts_token": "stsToken"
}
  • RamRoleArn
{
  "mode": "RamRoleArn",
  "access_key_id": "accessKeyId",
  "access_key_secret": "accessKeySecret",
  "ram_role_arn": "ramRoleArn",
  "ram_session_name": "ramSessionName"
}
  • EcsRamRole
{
  "mode": "EcsRamRole",
  "ram_role_name": "ramRoleName"
}

Example:

$ aliyun configure --mode External --profile externalTest
Configuring profile 'externalTest' in 'External' authenticate mode...
Process Command []: <getCredential ak>
Default Region Id []: cn-hangzhou
Default Output Format [json]: json (Only support json)
Default Language [zh|en] en: 
Saving profile[externalTest] ...Done.

Use chainable RamRoleArn

You can use --mode ChainableRamRoleArn to combile a source profile and RAM role ARN flow. The following example get intermediate credentials from source profile cli-test, then use it to call AssumeRole for get final credentials.

{
  "profiles": [
    {
      "name": "chain",
      "mode": "ChainableRamRoleArn",
      "ram_role_arn": "acs:ram::<Account ID>:role/<Role Name>",
      "ram_session_name": "session",
      "source_profile": "cli-test"
    },
    {
      "name": "cli-test",
      "mode": "AK",
      "access_key_id": "<Access Key ID>",
      "access_key_secret": "<Access Key Secret>"
    }
  ]
}

Use Credentials URI

You can use --mode CredentialsURI to get credentials from local/remote URI.

{
  "profiles": [
    {
      "name": "uri",
      "mode": "CredentialsURI",
      "credentials_uri": "http://localhost:6666/?user=jacksontian"
    }
  ]
}

The Credentials URI must be response with status code 200, and following body:

{
  "Code": "Success",
  "AccessKeyId": "<ak id>",
  "AccessKeySecret": "<ak secret>",
  "SecurityToken": "<security token>",
  "Expiration" "2006-01-02T15:04:05Z" // utc time
}

Otherwise, CLI treate as failure case.

Enable bash/zsh auto completion

  • Use aliyun auto-completion command to enable auto completion in zsh/bash
  • Use aliyun auto-completion --uninstall command to disable auto completion.

Use Alibaba Cloud CLI

Here is the basic usage guidelines. If you need a detailed manual, please visit Use Alibaba Cloud CLI

The Alibaba Cloud OpenAPI has two styles, RPC style and RESTful style. Most of the Alibaba Cloud products use the RPC style. The way of calling an API varies depending on the API style.

You can distinguish the API style from the following characteristics:

  • The API requiring the Action parameter is the RPC style, while the API requiring the PathPattern parameter is the RESTful style.
  • In general, the API style for a product is consistent.
  • Each API only supports one style. If an incorrect calling method is used, another API may be called or an error ApiNotFound is returned.

Call RPC APIs

The following statement shows how to call RPC APIs in the Alibaba Cloud CLI:

aliyun <product> <operation> --parameter1 value1 --parameter2 value2 ...

Examples:

aliyun rds DescribeDBInstances --PageSize 50
aliyun ecs DescribeRegions
aliyun rds DescribeDBInstanceAttribute --DBInstanceId xxxxxx

Call RESTful APIs

APIs of some products such as Container Service are RESTful style. The way to call RESTful APIs is different from RPC APIs.

The following examples show how to call RESTful APIs in the Alibaba Cloud CLI:

  • GET request:

    aliyun cs GET /clusters
  • POST request:

    aliyun cs POST /clusters --body "$(cat input.json)"
  • DELETE request:

    aliyun cs DELETE /clusters/ce2cdc26227e09c864d0ca0b2d5671a07

Get help information

Alibaba Cloud CLI integrates API descriptions for some products, you can get help by using the following commands:

  • aliyun help: get product list

  • aliyun help <product>: get the API information of a specific product

    For example, get help of ECS APIs: $ aliyun help ecs

  • $ aliyun help <product> <apiName>: get the detailed API information of a specific APU

    For example, get the help information of the CreateInstance API: aliyun help ecs CreateInstance

Use the --force option

Alibaba Cloud CLI integrates the product metadata of some products. It will validate API parameters when calling the API. If an API or a parameter that is not included in the metadata is used, an error unknown api or unknown parameter will be returned. You can use the --force option to skip the validation and call the API by force as shown in the following example:

aliyun newproduct --version 2018-01-01 --endpoint newproduct.aliyuncs.com --param1 ... --force

The following two options are required when using the --force option:

  • --version: the API version. You can find the API version in the API documentation. For example, the ECS API version is 2014-05-26.
  • --endpoint: the product endpoint. Get the product endpoint in the corresponding API documentation.

Use the --output parameter

The query interface of Alibaba Cloud products will return json structured data, which is inconvenient to read. Example:

aliyun ecs DescribeInstances

Executing the above command will get the following json result:

{
  "PageNumber": 1,
  "TotalCount": 2,
  "PageSize": 10,
  "RequestId": "2B76ECBD-A296-407E-BE17-7E668A609DDA",
  "Instances": {
    "Instance": [
      {
        "ImageId": "ubuntu_16_0402_64_20G_alibase_20171227.vhd",
        "InstanceTypeFamily": "ecs.xn4",
        "VlanId": "",
        "InstanceId": "i-12345678912345678123",
        "Status": "Stopped",
        //omit some fields
      },
      Instance": [
      {
        "ImageId": "ubuntu_16_0402_64_20G_alibase_20171227.vhd",
        "InstanceTypeFamily": "ecs.xn4",
        "VlanId": "",
        "InstanceId": "i-abcdefghijklmnopqrst",
        "Status": "Running",
        //omit some fields
      },
    ]
  }
}

You can use the --output parameter to extract the fields of interest in the results and perform tabular output. Example:

aliyun ecs DescribeInstances --output cols=InstanceId,Status rows=Instances.Instance[]

Executing the above command will get the following result:

InstanceId             | Status
-----------------------|--------
i-12345678912345678123 | Stopped
i-abcdefghijklmnopqrst | Running

When using the --output parameter, the following sub-parameters must be specified:

  • cols: The column names of the table, which need to correspond to the fields in the json data. For example, the InstanceId and Status fields in the result returned by the ECS DescribeInstances interface.

Optional sub-parameters:

  • rows: Use the jmespath query statement to specify the data source of the table row in the json result.

Use --waiter parameter

This parameter is used to poll the instance information until a specific state appears.

For example, after creating an instance using ECS, the instance will have a startup process. We will continue to query the running status of the instance until the status becomes "Running".

Example:

aliyun ecs DescribeInstances --InstanceIds '["i-12345678912345678123"]' --waiter expr='Instances.Instance[0].Status' to=Running

After executing the above command, the command line program will poll the instance status at a certain time interval and stop polling when the instance status becomes Running.

When using the --waiter parameter, you must specify the following two sub-parameters:

  • expr: Specify the polled field in the json result through the jmespath query statement.
  • to: The target value of the polled field.

Optional sub-parameters:

  • timeout: polling timeout time (seconds).
  • interval: polling interval (seconds).

Special argument

When you input some argument like "-PortRange -1/-1", will cause parse error. In this case, you could assign value like this: --PortRange=-1/-1.

Supported environment variables

We supported following environment variables:

  • ALIBABACLOUD_PROFILE/ALIBABA_CLOUD_PROFILE/ALICLOUD_PROFILE: When --profile flag is not specified, CLI use it.
  • ALIBABACLOUD_IGNORE_PROFILE=TRUE: When this variable is specified, CLI ignores any configuration files.
  • ALIBABACLOUD_ACCESS_KEY_ID/ALICLOUD_ACCESS_KEY_ID/ACCESS_KEY_ID: When no any specified Access Key Id, CLI use it.
  • ALIBABACLOUD_ACCESS_KEY_SECRET/ALICLOUD_ACCESS_KEY_SECRET/ACCESS_KEY_SECRET: When no any specified Access Key Secret, CLI use it.
  • ALIBABACLOUD_SECURITY_TOKEN/ALICLOUD_SECURITY_TOKEN/SECURITY_TOKEN: When no any specified Security Token, CLI use it.
  • ALIBABACLOUD_REGION_ID/ALICLOUD_REGION_ID/REGION: When no any specified Region Id, CLI use it.
  • DEBUG=sdk:Through this variable, CLI display http request information. It helpful for troubleshooting.

Getting Help

We use GitHub issues to track bugs and feature requests for user feedback. Please visit the following site for assistance:

More Repositories

1

oss-browser

OSS Browser 提供类似windows资源管理器功能。用户可以很方便的浏览文件,上传下载文件,支持断点续传等。
JavaScript
3,175
star
2

aliyun-openapi-java-sdk

Alibaba Cloud SDK for Java
Java
1,379
star
3

aliyun-oss-java-sdk

Aliyun OSS SDK for Java
Java
1,216
star
4

alibaba-cloud-sdk-go

Alibaba Cloud SDK for Go
Go
1,104
star
5

alicloud-android-demo

Java
990
star
6

aliyun-openapi-python-sdk

Alibaba Cloud SDK for Python
Python
980
star
7

aliyun-oss-php-sdk

Aliyun OSS SDK for PHP
PHP
975
star
8

aliyun-oss-go-sdk

Aliyun OSS SDK for Go
Go
951
star
9

aliyun-oss-python-sdk

Aliyun OSS SDK for Python
Python
935
star
10

darabonba

Darabonba 是一种用于 OpenAPI 的 DSL 语言,可以用来生成多语言的 SDK、Code Sample、Test Case 等代码
JavaScript
894
star
11

alibabacloud-alfa

阿里云微前端解决方案
TypeScript
845
star
12

aliyun-oss-android-sdk

Android SDK for aliyun object storage service
Java
793
star
13

ossfs

Export s3fs for aliyun oss.
C++
735
star
14

aliyun-openapi-php-sdk

[Abandoned] Open API SDK for PHP developers
PHP
605
star
15

terraform-provider-alicloud

Terraform AliCloud provider
Go
590
star
16

aliyun-openapi-net-sdk

Alibaba Cloud SDK for .NET
C#
535
star
17

rds_dbsync

围绕 PostgreSQL Greenplum ,实现易用的数据的互迁功能项目
C
528
star
18

openapi-sdk-php

Alibaba Cloud SDK for PHP
PHP
501
star
19

iotkit-embedded

高速镜像: https://code.aliyun.com/linkkit/c-sdk
C
492
star
20

ossutil

A user friendly command line tool to access AliCloud OSS.
Go
456
star
21

aliyun-oss-ios-sdk

iOS SDK for aliyun object storage service
Objective-C
450
star
22

aliyun-odps-python-sdk

ODPS Python SDK and data analysis framework
Python
433
star
23

alicloud-ios-demo

Demos for AMS iOS SDKs
Objective-C
431
star
24

alibabacloud-microservice-demo

An Alibaba Cloud native microservice demo powered by Apache Dubbo and Spring Cloud Alibaba
Java
379
star
25

api-gateway-demo-sign-java

aliyun api gateway request signature demo by java
Java
371
star
26

NeWCRFs

Python
365
star
27

aliyun-oss-csharp-sdk

Aliyun OSS SDK for C#
C#
360
star
28

surftrace

surftrace is a tool that allows you to surf the linux kernel
Python
332
star
29

conditional-lane-detection

Python
328
star
30

aliyun-log-jaeger

Go
294
star
31

coolbpf

C
240
star
32

tablestore-examples

Example code for aliyun tablestore.
Java
238
star
33

tablestore-timeline

TableStore-Timeline Model for Social scene
Java
236
star
34

aliyun-log-c-sdk

Aliyun LOG Producer for C/C++
C
215
star
35

openapi-sdk-php-client

Official repository of the Alibaba Cloud Client for PHP
PHP
214
star
36

aliyun-log-logback-appender

Java
186
star
37

aliyun-log-android-sdk

Java
179
star
38

alibabacloud-jindodata

alibabacloud-jindodata
176
star
39

openapi-core-nodejs-sdk

OpenAPI POP core SDK for Node.js
JavaScript
175
star
40

aliyun-emapreduce-datasources

Extended datasource support for Spark/Hadoop on Aliyun E-MapReduce.
Scala
168
star
41

aliyun-log-python-sdk

Use python to manage, produce and consume data with Aliyun Log Service.
Python
166
star
42

data-mapping-component

A React Component which focus on Data-Mapping & Table-Field-Mapping.(基于React的数据/表字段映射组件)
JavaScript
155
star
43

aliyun-oss-react-native

Objective-C
148
star
44

aliyun-apsaradb-hbase-demo

C++
146
star
45

django-oss-storage

Django storage backends for AliCloud OSS.
Python
144
star
46

aliyun-oss-c-sdk

Aliyun OSS SDK for C
C
144
star
47

react-visual-modeling

A DAG React Component for visualization modeling, suitable for UML, database modeling, data warehouse construction.(一个基于React的数据可视化建模的DAG图,适用于UML,数据库建模,数据仓库建设等业务)
JavaScript
138
star
48

aliyun-oss-ruby-sdk

Aliyun OSS SDK for Ruby
Ruby
138
star
49

ram-policy-editor

AliCloud RAM Policy Editor for OSS
JavaScript
136
star
50

aliyun-log-java-sdk

Java
135
star
51

serverless-aliyun-function-compute

Serverless Alibaba Cloud Function Compute Plugin – Add Alibaba Cloud Function Compute support to the Serverless Framework
JavaScript
134
star
52

alibabacloud-console-components

阿里云企业云管理平台 UI 组件库
TypeScript
133
star
53

aliyun-log-java-producer

Aliyun LOG Java Producer
Java
131
star
54

fc-nodejs-sdk

The Node.js SDK of FunctionCompute.
JavaScript
130
star
55

aliyun-cms-grafana

JavaScript
127
star
56

aliyun-odps-jdbc

JDBC Driver for ODPS
Java
125
star
57

alibabacloud-quantization-networks

alibabacloud-quantization-networks
Python
122
star
58

aliyun-emapreduce-demo

Java
121
star
59

aliyun-maxcompute-data-collectors

Java
119
star
60

alicloud-ams-demo

C#
117
star
61

alibabacloud-iot-device-sdk

alibaba cloud for iot device javascript SDK , connect with linkplatform , run at node/broswer/winxin min program /ali min program. 阿里云IoT物联网平台javascript版本sdk,可以运行在node/broswer/winxin min program /ali min program. 阿里云IoT物联网平台javascript版本sdk,可以运行在node/broswer/winxin min program /ali min program
JavaScript
110
star
62

MaxCompute-Spark

MaxCompute spark demo for building a runnable application.
Scala
106
star
63

api-gateway-nodejs-sdk

The API Gateway SDK for Node.js
JavaScript
104
star
64

cloud-design

阿里云前端组件库,由专有云&公有云前端团队共建
CSS
99
star
65

gm-jsse

开源国密通信纯 Java JSSE 实现
Java
95
star
66

aliyun-odps-console

ODPS Console Source Code.
Java
93
star
67

aliyun-openapi-cpp-sdk

Alibaba Cloud SDK for C++
C++
90
star
68

aliyun-odps-java-sdk

ODPS SDK for Java Developers
Java
89
star
69

aliyun-tablestore-nodejs-sdk

Aliyun TableStore(原OTS) SDK for Node.js
JavaScript
88
star
70

algorithm-base

让算法工程化更简单
Python
86
star
71

aliyun-log-ios-sdk

Aliyun LOG iOS SDK
Swift
84
star
72

iotx-api-demo

PHP
82
star
73

plugsched

Live upgrade Linux kernel scheduler subsystem
Python
82
star
74

DCT-Mask

Python
81
star
75

aliyun-openapi-nodejs-sdk

Alibaba Cloud SDK for Node.js
JavaScript
80
star
76

aliyun-specs

Aliyun Mobile Service CocoaPods specs.
Ruby
77
star
77

alibabacloud-console-design

阿里云管平台研发解决方案
TypeScript
77
star
78

alibabacloud-redis-training-demo

Java
76
star
79

aliyun-oss-php-sdk-laravel

A Laravel service provider for the AliCloud OSS SDK for PHP
PHP
75
star
80

aliyun-tablestore-go-sdk

TableStore SDK for Golang
Go
75
star
81

alibabacloud-sdk

Tea
75
star
82

fc-docker

Dockerfiles for local building or running function of FC
Dockerfile
74
star
83

elasticsearch-repository-oss

Java
74
star
84

dro-sfm

Python
74
star
85

packagist-mirror

Alibaba Cloud Packagist Mirror
Go
73
star
86

react-monitor-dag

A React-based operation/monitoring DAG diagram.(基于React的运维/监控DAG图)
JavaScript
69
star
87

aliyun_assist_client

Aliyun Assist Client 阿里云 云助手
Go
67
star
88

aliyun-log-php-sdk

PHP
67
star
89

alibabacloud-hologres-connectors

alibabacloud-hologres-connectors
Java
66
star
90

aliyun-tsdb-java-sdk

Aliyun TSDB SDK for Java
Java
64
star
91

aliyun-log-log4j-appender

aliyun-log-log4j-appender
Java
63
star
92

fc-java-sdk

The Java SDK of FunctionCompute.
Java
61
star
93

oss-ftp

The ftp proxy for Aliyun OSS.
Python
61
star
94

react-lineage-dag

JavaScript
61
star
95

aliyun-log-cli

Command Line Interface for Aliyun Log Service
Python
60
star
96

csb-sdk

The CSB-SDK is a client-side invocation SDK for HTTP or Web Service API opened by the CSB (Cloud Service Bus) product. It is responsible for invoking the open API and signing the request information.
Java
58
star
97

ossimport

Data migration tool
58
star
98

aliyun-log-flink-connector

flink log connector
Java
58
star
99

oss-emulator

OSS Emulator
Ruby
58
star
100

aliyun-log-dotnetcore-sdk

C#
55
star