Before you use Alibaba Cloud CLI, you must configure the information that is required to call Alibaba Cloud resources. This information includes the credential, region, and language.

Credential types

To specify the credential type, you can add the --mode <authenticationMethod> option to the configure command in Alibaba Cloud CLI. The following table describes the supported credential types.

Credential type Description Interactive credential configuration (fast) Non-interactive credential configuration
AK Use the AccessKey ID and AccessKey secret for access. Configure the AccessKey pair Configure the AccessKey pair
StsToken Use the Security Token Service (STS) token for access. Configure the STS token Configure the STS token
RamRoleArn Use the role of a Resource Access Management (RAM) user for access. Configure the RamRoleArn credential Configure the RamRoleArn credential
EcsRamRole Use the RAM role of an Elastic Compute Service (ECS) instance for password-free access. Configure the EcsRamRole credential Configure the EcsRamRole credential
Note In the preceding credential types, only EcsRamRole does not require the AccessKey information.

Credential configuration methods

You can specify the credential type and configure the credential in Alibaba Cloud CLI in interactive or non-interactive mode. The following section describes how to configure the credential in Alibaba Cloud CLI in interactive mode. For information about how to configure the credential in non-interactive mode, see Method of configuring credentials.

  • Interactive configuration (fast): In this mode, the configuration can be performed in a fast and convenient manner. You need only to enter the required information as prompted.
  • Non-interactive configuration: In this mode, all the required information is configured through a single command line. This information includes the profile name, credential type, and authentication information that is required for the credential.

Interactive configuration

Run the configure command to configure the credential. Use the following command syntax:

aliyun configure --mode <AuthenticateMode> --profile <profileName>

You must configure the following configuration options:

  • --profile: specifies the profile name. If the specified profile already exists, modify the profile. If the specified profile does not exist, create a profile.
  • --mode: specifies the type of the credential. Valid values: AK, StsToken, RamRoleArn, and EcsRamRole.

In interactive configuration mode, you are prompted to enter the required information, including the AccessKey information and region ID.

  • Make sure that the AccessKey information that you enter is correct. Otherwise, accidental operations may occur, or API operations may fail to be called.
    Note You can create and view your AccessKey pair on the AccessKey page in the Alibaba Cloud Management Console, or contact your system administrator to obtain the AccessKey pair.
  • For more information about the region IDs supported by Alibaba Cloud, see Regions and zones.

Configure the AccessKey credential

In Alibaba Cloud CLI, the AccessKey credential type is named AK and is the default credential type. Therefore, you can omit the --mode option when you configure the AccessKey credential in interactive mode.

The following example shows how to configure an AccessKey credential named akProfile:

aliyun configure --profile akProfile
Configuring profile 'akProfile' in ''
authenticate mode...
Access Key Id []: AccessKey ID
Access Key Secret []: AccessKey Secret
Default Region Id []: cn-hangzhou
Default Output Format [json]: json (Only support json))
Default Language [zh|en] en:
Saving profile[akProfile] ...Done.

Configure the auto-complete feature

When you use Alibaba Cloud CLI, you can run the following commands to enable or disable the auto-complete feature. Only Z shell (Zsh) or Bash shell is supported.

  • Enable the auto-complete feature
    aliyun auto-completion
  • Disable the auto-complete feature
    aliyun auto-completion --uninstall