Configure or modify a profile
You can use the aliyun configure
command to quickly configure or modify profiles.
Syntax
aliyun configure
aliyun configure --mode <AuthenticateMode> --profile <profileName>
--mode
: the credential type. If you do not specify this parameter, this parameter is set to AK, which indicates AccessKey pairs.
--profile
: 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.
Method 1: aliyun configure
Quickly modify or configure the default profile. In this example, the default
profile is configured. The settings are for reference only and you can configure the parameters based on your business requirements. For more information about how to modify the default profile, see the Method 1: aliyun configure set --profile <profileName> section of this topic.
Example
Command
aliyun configure
Sample response
Configuring profile 'default' in 'AK' authenticate mode...
Access Key Id []: *********************
Access Key Secret []: *********************
Default Region Id []: cn-hangzhou
Default Output Format [json]: json (Only support json)
Default Language [zh|en] en: en
Saving profile[profile] ...Done.
Method 2: aliyun configure --mode <mode> --profile <profileName>
Quickly configure a profile of a specific credential type. In this example, the AkProfile
profile of the AK
type is configured. The settings are for reference only and you can configure the parameters based on your business requirements.
Example
Command
aliyun configure --mode AK --profile AkProfile
Sample response
Configuring profile 'AkProfile' in 'AK' authenticate mode...
Access Key Id []: *********************
Access Key Secret []: *********************
Default Region Id []: cn-hangzhou
Default Output Format [json]: json (Only support json)
Default Language [zh|en] en: en
Saving profile[profile] ...Done.
List the information about all profiles
You can use the list
command to view a summary of all profiles.
Example
Command
aliyun configure list
Sample response
The following information is returned, including the name, masked credential, language, and default region ID of each profile. The profile whose name is marked with an asterisk (∗) is the default profile.
Profile | Credential | Valid | Region | Language
--------- | ------------------ | ------- | ---------------- | --------
akProfile * | AK:***yId | Valid | cn-hangzhou | en
stsTokenProfile | StsToken:***yId | Valid | cn-hangzhou | en
ramRoleArnProfile | RamRoleArn:***yId | Valid | cn-hangzhou | en
ecsRamRoleProfile | EcsRamRole:EcsRamRole | Valid | cn-hangzhou | en
View the details of a profile
You can use the get
command to view the details of a profile.
Syntax
aliyun configure get
aliyun configure get --profile <profileName>
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 the command is run. For more information about the valid values of the settingName parameter, see the Configuration items supported by the get command section of this topic.
--profile
: 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.
Method 1: aliyun configure get
View the information about the default profile.
Example
Command
aliyun configure get
Sample response
{
"name": "default",
"mode": "AK",
"access_key_id": "********************",
"access_key_secret": "***********************",
"sts_token": "",
"sts_region": "",
"ram_role_name": "",
"ram_role_arn": "",
"ram_session_name": "",
"source_profile": "",
"private_key": "",
"key_pair_name": "",
"expired_seconds": 0,
"verified": "",
"region_id": "cn-hangzhou",
"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: aliyun configure get --profile <profileName>
View the information about a profile. In this example, the exampleProfile
profile is used.
Example
Command
aliyun configure get --profile exampleProfile
Sample response
{
"name": "exampleProfile",
"mode": "AK",
"access_key_id": "********************",
"access_key_secret": "***********************",
"sts_token": "",
"sts_region": "",
"ram_role_name": "",
"ram_role_arn": "",
"ram_session_name": "",
"source_profile": "",
"private_key": "",
"key_pair_name": "",
"expired_seconds": 0,
"verified": "",
"region_id": "cn-hangzhou",
"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: aliyun configure get [settingName]... --profile <profileName>
View a configuration item of a profile. In this example, the mode
configuration item of the exampleProfile
profile is queried. mode indicates the credential type. The CLI returns the information in the settingName=value
format.
Example
Command
aliyun configure get mode --profile exampleProfile
Sample response
mode=AK
Modify a profile
You can use the set
command to modify a profile.
Syntax
aliyun configure set --profile <profileName>
aliyun configure set [--settingName <settingValue>]...
aliyun configure set [--settingName <settingValue>]... --profile <profileName>
aliyun configure set [--settingName <settingValue>]... --profile <profileName> --region <regionId>
--profile
: 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.
--settingName
: the configuration item to be modified. For more information, see the Configuration items supported by the set command section of this topic.
The order of the --settingName
and --profile
parameters does not affect the command output.
No response is returned after the set
command is run. You can use the get
or list
command to view the modification results.
Method 1: aliyun configure set --profile <profileName>
Set an existing profile as the default profile. In this example, the exampleProfile
profile is used.
Example
Command
aliyun configure set --profile exampleProfile
Use the list
command to view the modification result.
Profile | Credential | Valid | Region | Language
--------- | ------------------ | ------- | ---------------- | --------
default | AK:***yId | Valid | cn-hangzhou | en
exampleProfile * | AK:***yId | Valid | cn-beijing | en
Method 2: aliyun configure set [--settingName <settingValue>]...
Modify the configurations of the default profile. In this example, the language
configuration item is used.
Example
Command
aliyun configure set --language cn
Use the get
command to view the modification result.
language=cn
Method 3: aliyun configure set [--settingName <settingValue>]... --profile <profileName>
Modify the configurations of a profile. In this example, the region_id
configuration item of the exampleProfile
profile is modified
Example
Command
aliyun configure set --region cn-hangzhou --profile exampleProfile
Use the get
command to view the modification result.
cn-hangzhou
Method 4: aliyun configure set [--settingName <settingValue>]... --profile <profileName> --region <regionId>
Create a profile of a specific credential type. You must specify all the parameters required for the specified credential type. Otherwise, the creation fails. For more information about the required parameters for each credential type, see the Identity credential types section of the "Configure identity credentials" topic.
In this example, the AkProfile
profile of the AK
type is created.
Example
Command
aliyun configure set
--profile akProfile
--mode AK
--region cn-beijing
--access-key-id AccessKeyId
--access-key-secret AccessKeySecret
Use the list
command to view the result.
Profile | Credential | Valid | Region | Language
--------- | ------------------ | ------- | ---------------- | --------
default | AK:***yId | Valid | cn-hangzhou | en
akProfile * | AK:***yId | Valid | cn-beijing | en
Delete a profile
You can run the delete
command to delete a profile.
Syntax
aliyun configure delete --profile <profileName>
--profile
: the profile name. If you do not specify this parameter, the operation fails.
If the default profile is deleted, the first profile in the profile list automatically becomes the default profile. For more information, see the example.
We recommend that you retain at least one profile. If you accidentally delete all profiles, the following error message is returned when you run commands in Alibaba Cloud CLI.
ERROR: load current configuration failed unknown profile default, run configure to check
To resolve this issue, you must delete the config.json
file, which is stored in the .aliyun
folder of your personal user directory.
Example
The following code shows how to delete a profile and the profile list before and after the deletion. In this example, the exampleProfile
profile is deleted.
The profile list before deletion
Profile | Credential | Valid | Region | Language
--------- | ------------------ | ------- | ---------------- | --------
default | AK:***yId | Valid | cn-hangzhou | en
AkProfile | AK:***yId | Valid | cn-hangzhou | en
exampleProfile * | AK:***yId | Valid | cn-hangzhou | en
Command
aliyun configure delete --profile exampleProfile
The profile list after deletion
Profile | Credential | Valid | Region | Language
--------- | ------------------ | ------- | ---------------- | --------
default * | AK:***yId | Valid | cn-hangzhou | en
AkProfile | AK:***yId | Valid | cn-hangzhou | en
Help information
Configuration items supported by the set
command
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> |
--sts-token | The Security Token Service (STS) token . | --sts-token <StsToken> |
--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 |
--skip-secure-verify | Skips HTTPS certificate verification. This parameter is not recommended. | --skip-secure-verify |
--expired-seconds | The expiration time of the credential. | --expired-seconds <seconds> |
Configuration items supported by the get
command
Value of the settingName parameter | Comfiguration item |
profile | name: the profile name. |
mode | mode: the credential type. |
access-key-id | access_key_id |
access-key-secret | access_key_secret |
sts-token | sts_token |
sts-region | sts_region |
ram-role-name | ram_role_name |
ram-role-arn | ram_role_arn |
role-session-name | ram_session_name |
private-key | private_key: the private key of the Rivest–Shamir–Adleman (RSA) key pair. |
key-pair-name | key_pair_name: the name of the RSA key pair. |
region | region_id |
language | language |