Before you use Alibaba Cloud CLI, you must configure the credential that is required for calling Alibaba Cloud resources. The credential information includes the credential, region, and language.
When you configure a credential, make sure that the credential information is correct. Otherwise, user errors or API call failures may cause business losses.
Credential configuration methods
Alibaba Cloud CLI allows you to configure credential in interactive and non-interactive modes. The interactive mode guides you through the configuration process. This way, you can configure a profile in Alibaba Cloud CLI at a low learning cost.
Interactive mode
Common syntax
You can run the aliyun configure command to configure a credential in interactive mode. Syntax:
aliyun configure [--profile <PROFILE_NAME>] [--mode <AUTHENTICATE_MODE>]Command options:
PROFILE_NAME: The name of the profile.If the specified profile exists, it is overwritten. If the specified profile does not exist, a profile with the specified name is created.
If you do not specify a profile, the current profile is modified. For more information about how to modify the current profile, see the "Set the current profile" section in this topic.
AUTHENTICATE_MODE: The identity credential type. Default value: AK. For more information about the supported credential types, see the "Credential types" section in this topic.
Sample success response:
Configure Done!!!
..............888888888888888888888 ........=8888888888888888888D=..............
...........88888888888888888888888 ..........D8888888888888888888888I...........
.........,8888888888888ZI: ...........................=Z88D8888888888D..........
.........+88888888 ..........................................88888888D..........
.........+88888888 .......Welcome to use Alibaba Cloud.......O8888888D..........
.........+88888888 ............. ************* ..............O8888888D..........
.........+88888888 .... Command Line Interface(Reloaded) ....O8888888D..........
.........+88888888...........................................88888888D..........
..........D888888888888DO+. ..........................?ND888888888888D..........
...........O8888888888888888888888...........D8888888888888888888888=...........
............ .:D8888888888888888888.........78888888888888888888O ..............Non-interactive mode
Common syntax
You can run the aliyun configure set command to configure a credential in non-interactive mode. Syntax:
aliyun configure set [--profile <PROFILE_NAME>] [--mode <AUTHENTICATE_MODE>] [--settingName <SETTING_VALUE>...]Command options:
ProfileName: The name of the profile. If the specified profile exists, it is overwritten. If the specified profile does not exist, a profile with the specified name is created.AUTHENTICATE_MODE: The credential type. Default value: AK. For more information about the supported credential types, see the "Credential types" section in this topic.SETTING_VALUE: The information that you need to specify varies based on the credential type. For more information, see the "Credential types" section in this topic and the "Non-interactive mode" section in Profile-related commands.
After you configure a credential in non-interactive mode, you can run the aliyun configure list or aliyun configure get command to check whether the credential is configured as expected.
Credential types
Alibaba Cloud CLI provides the following credential types. You can configure them as needed.
Credential type | Credential refresh policy | Key-free access |
Manual refresh | Not supported | |
Manual refresh | Not supported | |
Automatic refresh | Not supported | |
Automatic refresh | Supported | |
Refreshed by an external system | Supported | |
Follows the refresh policy of the preceding credential | Supported | |
Refreshed by an external system | Supported | |
Automatic refresh | Supported | |
Requires browser logon | Supported | |
Requires browser interaction for initial authorization. Can be auto-refreshed later. | Supported |
Credential management
Alibaba Cloud CLI allows you to configure and manage multiple sets of credentials. You can switch between or specify profiles as needed.
Use the current profile
Run the following command to switch from the current profile to a specific profile.
aliyun configure switch --profile <PROFILE_NAME>After the switch is successful, Alibaba Cloud CLI uses the settings and credentials in this profile by default until you make another change.
You can also run the aliyun configure set command to modify a credential's profile settings. The modified settings are used.
Specify a profile
When you run a command, you can use the --profile option to explicitly specify the profile to use. This method has the highest priority and overwrites the configurations of other methods.
Example: Call the DescribeInstances operation of Elastic Compute Service by using the credential named exampleProfile to query the information about Elastic Compute Service instances.
aliyun ecs DescribeInstances --profile exampleProfileOther credential management commands
Alibaba Cloud CLI provides the configure command and its sub-commands to manage multiple identity credentials. You can use these commands to add, delete, modify, and view credentials. For more information, see Manage multiple credentials.
Storage locations of credentials
A credential profile specifies a set of configuration items and has a custom name. All profiles are stored in the config.json file in the JSON format. This file is located in the .aliyun folder in your personal user directory. The path of the folder varies with the operating system.
Windows:
C:\Users\<USERNAME>\.aliyunLinux/macOS:
/home/ <USER_NAME> /.aliyun


