This topic describes how to use profile-related commands of Alibaba Cloud CLI.
Specify the default profile
You can run the aliyun configure switch
command to specify a profile as the default profile. This command is supported only in Alibaba Cloud CLI V3.0.216
or later.
Example: Specify a profile as the default profile
Syntax
aliyun configure switch --profile <profileName>
--profile <profileName>
: the profile name. This parameter is required.Example
Run the
aliyun configure list
command to view the profile list before you specify the default profile. By default, a profile nameddefault
is created and used as the default profile, and the profile name is marked with an asterisk (∗).Profile | Credential | Valid | Region | Language --------- | ------------------ | ------- | ---------------- | -------- default * | AK:**** | Valid | cn-hangzhou | en exampleProfile | AK:**** | Valid | cn-beijing | zh
Run the following command to specify the
exampleProfile
profile as the default profile:aliyun configure switch --profile exampleProfile
Alibaba Cloud CLI returns the following information:
The default profile is 'exampleProfile' now.
Run the
aliyun configure list
command to view the profile list after the default profile is specified. The name of theexampleProfile
profile is marked with an asterisk (∗), indicating that it is the default profile.Profile | Credential | Valid | Region | Language --------- | ------------------ | ------- | ---------------- | -------- default | AK:**** | Valid | cn-hangzhou | en exampleProfile * | AK:**** | Valid | cn-beijing | zh
Configure a profile in interactive mode
You can run the aliyun configure
command to configure a profile in interactive mode. The method of using this command varies based on the parameters used.
Method 1: Configure the default profile in interactive mode
Syntax
aliyun configure
Example
Run the following command to configure the default profile in interactive mode. If you use this command to modify the default profile, the original credential type of the default profile is preferentially used.
NoteYou can run the
aliyun configure switch
command to specify the default profile. For more information, see the Specify the default profile section of this topic.aliyun configure
The following sample response shows the interaction process:
Configuring profile 'default' in 'AK' authenticate mode... Access Key Id []: **** Access Key Secret []: **** Default Region Id []: **** Default Output Format [json]: json (Only support json) Default Language [zh|en] en: en Saving profile[profile] ...Done.
Method 2: Configure a specific profile in interactive mode
Syntax
aliyun configure --mode <AuthenticateMode> --profile <profileName>
--mode <AuthenticateMode>
: the credential type.If you do not specify this parameter, the default credential type AK is used.
For more information about the credential types supported by Alibaba Cloud CLI, see the "Credential types" section of the Configure profiles topic.
--profile <profileName>
: the profile name. If you do not specify this parameter, the default profile is used. If the specified profile does not exist, a profile with the specified name is created.
Example
Run the following command to configure the
AkProfile
profile of the AK credential type in interactive mode:aliyun configure --mode AK --profile AkProfile
The following sample response shows the interaction process:
Configuring profile 'AkProfile' in 'AK' authenticate mode... Access Key Id []: **** Access Key Secret []: **** Default Region Id []: **** Default Output Format [json]: json (Only support json) Default Language [zh|en] en: en Saving profile[profile] ...Done.
Configure a profile in non-interactive mode
You can run the aliyun configure set
command to configure a profile in non-interactive mode. The method of using this command varies based on the parameters used.
After a profile is modified, Alibaba Cloud CLI sets the modified profile as the default profile.
Method 1: Configure a profile in non-interactive mode
Syntax
aliyun configure set [--settingName <settingValue>]... --mode <AuthenticateMode> --profile <profileName>
--settingName <settingValue>
: the configuration item that you want to modify. For more information, see the Parameters of the set command section of this topic. When you create a profile of a specific credential type, you must specify all the parameters required for the specified credential type. Otherwise, the profile fails to be created.--mode <AuthenticateMode>
: the credential type. If you do not specify this parameter, the default credential type AK is used. For more information about the credential types supported by Alibaba Cloud CLI, see the "Credential types" section of the Configure profiles topic.--profile <profileName>
: the profile name. If you do not specify this parameter, the default profile is used. If the specified profile does not exist, a profile with the specified name is created.
Example
Run the following command to configure the
AkProfile
profile of the AK credential type in non-interactive mode:aliyun configure set \ --access-key-id **** \ --access-key-secret **** \ --region **** \ --profile AkProfile \ --mode AK
Run the
aliyun configure list
command to view the result.Profile | Credential | Valid | Region | Language --------- | ------------------ | ------- | ---------------- | -------- default | AK:**** | Valid | **** | en AK_Profile * | AK:**** | Valid | **** | en
Method 2: Modify a specific profile
Syntax
aliyun configure set [--settingName <settingValue>]... --profile <profileName>
--settingName <settingValue>
: the configuration item that you want to modify. For more information, see the Parameters of the set command section of this topic.--profile <profileName>
: the profile name. If you do not specify this parameter, the default profile is used. If the specified profile does not exist, a profile with the specified name is created.
Example
Run the following command to change the value of the
region_id
parameter in theexampleProfile
profile tocn-hangzhou
:aliyun configure set --region cn-hangzhou --profile exampleProfile
Run the
aliyun configure get region --profile example
command to view the result.cn-hangzhou
Obtain the profile list
You can run the aliyun configure list
command to obtain the profile list. You can view the summary of all profiles in the profile list.
Example: Obtain the profile list
Run the following command to view the summary of all profiles:
aliyun configure list
Alibaba Cloud CLI returns the name, encrypted credential information, language, and default region of each profile. The name of the current default profile is marked with an asterisk (∗).
Profile | Credential | Valid | Region | Language --------- | ------------------ | ------- | ---------------- | -------- akProfile * | AK:**** | Valid | **** | en stsTokenProfile | StsToken:**** | Valid | **** | en ramRoleArnProfile | RamRoleArn:**** | Valid | **** | en ecsRamRoleProfile | EcsRamRole:**** | Valid | **** | zh
View a profile
You can run the aliyun configure get
command to view the details of a profile. The method of using this command varies based on the parameters used.
Method 1: View all the information about the default profile
Syntax
aliyun configure get
Example
Run the following command to view the details of the default profile:
NoteYou can run the
aliyun configure switch
command to specify the default profile. For more information, see the Specify the default profile section of this topic.aliyun configure get
Sample response:
{ "name": "default", "mode": "AK", "access_key_id": "****", "access_key_secret": "****", "sts_region": "", "ram_role_name": "", "ram_role_arn": "", "ram_session_name": "", "source_profile": "", "private_key": "", "key_pair_name": "", "expired_seconds": 0, "verified": "", "region_id": "****", "output_format": "json", "language": "en", "site": "", "retry_timeout": 0, "connect_timeout": 0, "retry_count": 0, "process_command": "", "credentials_uri": "", "oidc_provider_arn": "", "oidc_token_file": "" }
Method 2: View all the information about a specific profile
Syntax
aliyun configure get --profile <profileName>
--profile <profileName>
: the profile name. If you do not specify this parameter, the default profile is used. If the specified profile does not exist,profile profileName not found!
is returned.Example
Run the following command to view the details of the
exampleProfile
profile of the External credential type:aliyun configure get --profile exampleProfile
Sample response:
{ "name": "exampleProfile", "mode": "External", "access_key_id": "", "access_key_secret": "", "sts_region": "", "ram_role_name": "", "ram_role_arn": "", "ram_session_name": "", "source_profile": "", "private_key": "", "key_pair_name": "", "expired_seconds": 0, "verified": "", "region_id": "****", "output_format": "json", "language": "en", "site": "", "retry_timeout": 0, "connect_timeout": 0, "retry_count": 0, "process_command": "****", "credentials_uri": "", "oidc_provider_arn": "", "oidc_token_file": "" }
Method 3: View some information about the default profile
Syntax
aliyun configure get [settingName]...
settingName
: the configuration item that you want to view. If you do not specify this parameter, all configuration items of the profile are returned. If the specified configuration item does not exist, no result is returned after this command is run. For more information, see the Parameters of the get command section of this topic.
Example
Run the following command to view the name, credential type, and default language of the profile named
default
:NoteYou can run the
aliyun configure switch
command to specify the default profile. For more information, see the Specify the default profile section of this topic.aliyun configure get profile mode language --profile default
Alibaba Cloud CLI returns the profile details in the
settingName=value
format.profile=default mode=AK language=en
Method 4: View some information about a specific profile
Syntax
aliyun configure get [settingName]... --profile <profileName>
settingName
: the configuration item that you want to view. If you do not specify this parameter, all configuration items of the profile are returned. If the specified configuration item does not exist, no result is returned after this command is run. For more information, see the Parameters of the get command section of this topic.--profile <profileName>
: the profile name. If the specified profile does not exist,profile profileName not found!
is returned.
Example
Run the following command to view the name, credential type, and default language of the
exampleProfile
profile whose credential type is External:aliyun configure get profile mode language --profile exampleProfile
Alibaba Cloud CLI returns the profile details in the
settingName=value
format.profile=exampleProfile mode=External language=en
Delete a profile
You can run the aliyun configure delete
command to delete a profile.
Example: Delete a profile
Syntax
aliyun configure delete --profile <profileName>
--profile
: the profile that you want to delete. This parameter is required. If you do not specify this parameter or the profile does not exist, this command fails to be run.If the default profile is deleted, the first profile in the profile list automatically becomes the new default profile. For more information, see the example in this section.
We recommend that you retain at least one profile. If you accidentally delete all profiles, Alibaba Cloud CLI reports errors when you run commands in Alibaba Cloud CLI. To resolve this issue, you must delete the
config.json
file that is stored in the.aliyun
folder of your personal user directory.
Example
Run the
aliyun configure list
command to view the profile list before you delete a profile.Profile | Credential | Valid | Region | Language --------- | ------------------ | ------- | ---------------- | -------- default | AK:**** | Valid | cn-hangzhou | en AkProfile | AK:**** | Valid | cn-hangzhou | en exampleProfile * | AK:**** | Valid | cn-hangzhou | en
Run the following command to delete the
exampleProfile
profile:aliyun configure delete --profile exampleProfile
Run the
aliyun configure list
command to view the profile list after the profile is deleted. TheexampleProfile
profile is deleted, and the profile nameddefault
is set as the default profile.Profile | Credential | Valid | Region | Language --------- | ------------------ | ------- | ---------------- | -------- default * | AK:**** | Valid | cn-hangzhou | en AkProfile | AK:**** | Valid | cn-hangzhou | en
Help information
Parameters of the set command
Parameters
Parameter
Description
Example
--access-key-id
The
AccessKey ID
.--access-key-id <AccessKeyId>
--access-key-secret
The
AccessKey secret
.--access-key-secret <AccessKeySecret>
--ram-role-name
The
name of the Resource Access Management (RAM) role
.--ram-role-name <RamRoleName>
--ram-role-arn
The
Alibaba Cloud Resource Name (ARN) of the RAM role
.--ram-role-arn <RamRoleArn>
--role-session-name
The
session name of the RAM role
.--role-session-name <RoleSessionName>
--language
The language.
--language [en|zh]
--region
The region.
--region cn-hangzhou
--read-timeout
The I/O timeout period, in seconds.
--read-timeout 10
--connect-timeout
The connection timeout period, in seconds.
--connect-timeout 10
--retry-count
The number of retry attempts.
--retry-count 5
--expired-seconds
The expiration time of the credential.
--expired-seconds <seconds>
--process-command
The command of the external program.
--process-command <ProcessCommand>
--oidc-provider-arn
The ARN of the OpenID Connect (OIDC) identity provider (IdP).
--oidc-provider-arn <OIDCProviderARN>
--oidc-token-file
The path of the OIDC token file.
--oidc-token-file <OIDCTokenFile>
Parameters of the get command
Parameters
Value of the settingName parameter
Configuration item in a profile
profile
name
mode
mode
access-key-id
access_key_id
access-key-secret
access_key_secret
sts-region
sts_region
ram-role-name
ram_role_name
ram-role-arn
ram_role_arn
role-session-name
ram_session_name
region
region_id
language
language