Environment variables for Alibaba Cloud CLI

Updated at:
Copy as MD

The Alibaba Cloud CLI supports configuring credentials, region, behavior options, and other runtime parameters using environment variables. In CI/CD pipelines, container environments, or automation scripts, environment variables are the preferred method for passing credentials and runtime configuration. This topic lists all supported environment variables and explains their priority order to help you quickly locate the required configuration items.

Priority order

When reading configuration, the Alibaba Cloud CLI applies settings in the following priority order, from highest to lowest:

  1. Command-line parameters (such as --profile and --region)

  2. Configuration file (~/.aliyun/config.json)

  3. Environment variables

For more information, see Understand command-line parameters.

Credentials and identity

Use environment variables to configure credential information such as AccessKey, Security Token Service (STS) token, OpenID Connect (OIDC), and RAM roles without storing secrets in plaintext in configuration files.

Environment variable

Description

ALIBABA_CLOUD_ACCESS_KEY_ID

AccessKey ID.

ALIBABA_CLOUD_ACCESS_KEY_SECRET

AccessKey Secret.

ALIBABA_CLOUD_SECURITY_TOKEN

STS temporary security token. Use together with AccessKey ID and AccessKey Secret.

ALIBABA_CLOUD_CREDENTIALS_URI

Credential service endpoint for CredentialsURI mode. No alias available.

ALIBABA_CLOUD_OIDC_PROVIDER_ARN

ARN (Alibaba Cloud Resource Name) of the OIDC identity provider.

ALIBABA_CLOUD_OIDC_TOKEN_FILE

Path to the OIDC token file.

ALIBABA_CLOUD_ROLE_ARN

RAM role ARN, used with RamRoleArn and ChainableRamRoleArn authentication modes.

ALIBABA_CLOUD_EXTERNAL_ID

External ID, used in cross-account role assumption scenarios.

ALIBABA_CLOUD_SSO_CLIENT_ID

Client ID of the application used for Cloud SSO sign-in. When unset, the CLI uses its built-in official application (app-vaz16tltdxs96audqf35). You rarely need to change it.

For configuration methods and applicable scenarios for each credential type, see Configure credentials.

Profile selection

Control which profile the CLI uses.

Environment variable

Description

ALIBABA_CLOUD_PROFILE

Specifies the profile to use. Equivalent to the --profile parameter. When unset, the CLI uses the current profile from the configuration file.

ALIBABA_CLOUD_IGNORE_PROFILE

When set to TRUE (must be uppercase and is case-sensitive), the CLI ignores profiles in the configuration file and uses only credentials provided by environment variables. When unset, the CLI reads profiles from the configuration file as usual.

Region and endpoint

Environment variable

Description

ALIBABA_CLOUD_REGION_ID

Default region ID, such as cn-hangzhou. When unset and the profile also has no region, calls that require a region fail.

ALIBABA_CLOUD_ENDPOINT

Custom API endpoint address. When set, the CLI sends requests directly to this address and skips automatic endpoint resolution. When unset, the CLI automatically resolves the endpoint based on the service and region.

ALIBABA_CLOUD_ENDPOINT_TYPE

Endpoint type. For example, set to vpc to use a VPC private network endpoint. Leave empty or unset to use the public network endpoint.

ALIBABA_CLOUD_STS_ENDPOINT

A custom endpoint for the STS service. Used in authentication modes that need to call STS to obtain temporary credentials, such as RamRoleArn and ChainableRamRoleArn. When unset, the CLI automatically selects the public STS endpoint of the region.

Plugin management

Control plugin auto-installation behavior, storage location, and download source.

Environment variable

Description

ALIBABA_CLOUD_CLI_PLUGIN_AUTO_INSTALL

When set to true, the CLI automatically installs missing plugins when invoking plugin commands. When unset, plugins are not installed automatically.

ALIBABA_CLOUD_CLI_PLUGIN_AUTO_INSTALL_ENABLE_PRE

When set to true, allows automatic installation of pre-release plugin versions. When unset, pre-release versions are not installed.

ALIBABA_CLOUD_CLI_PLUGINS_DIR

Custom plugin installation directory. Default is ~/.aliyun/plugins/.

ALIBABA_CLOUD_CLI_PLUGIN_NO_CACHE

When set to true, bypasses the plugin index cache and fetches the latest index from the remote source every time. When unset, the plugin index cache is used.

ALIBABA_CLOUD_CLI_PLUGIN_SOURCE_BASE

Base URL for a custom plugin download source. Useful in private network environments or private image scenarios. When unset, the official default plugin source https://aliyuncli.alicdn.com/plugins-v2 is used.

Network, timeout, and language

The timeout, retry, and language variables in the following table are passed by the CLI to plugins. To set the timeout, retry, and language for the CLI's own commands, use the --read-timeout, --connect-timeout, --retry-count, and --language parameters, or use aliyun configure. When unset, the CLI's own calls default to a 10-second read timeout and a 5-second connection timeout.

Environment variable

Description

ALIBABA_CLOUD_READ_TIMEOUT

I/O read timeout, in seconds.

ALIBABA_CLOUD_CONNECT_TIMEOUT

Connection timeout, in seconds.

ALIBABA_CLOUD_RETRY_COUNT

Number of retries on request failure.

ALIBABA_CLOUD_LANGUAGE

The language setting passed to plugins. Valid values: en (English) and zh (Chinese). The CLI's own output language is determined by the --language parameter and defaults to English.

AI Mode and agent integration

Controls AI Mode and automatic integration in agent environments. For more information about AI Mode, see AI Mode.

Environment variable

Description

ALIBABA_CLOUD_CLI_AI_MODE

Enables or disables AI Mode for the current process, taking precedence over the configuration file. Set to true to enable or false to disable. When unset, the configuration file prevails.

ALIBABA_CLOUD_CLI_AGENT_INTEGRATION

Controls whether the corresponding integration is automatically enabled when an agent environment is detected. When unset, the default behavior is kept (automatically enabled). Set to disabled to turn off all integrations, or all to enable all. You can also use a comma-separated allow list to enable only specified integrations (such as ai-mode).

Safety Policy

Controls Safety Policy through environment variables, which take precedence over the configuration file. For more information about Safety Policy, see Safety policy.

Environment variable

Description

ALIBABA_CLOUD_SAFETY_POLICY_ENABLED

Overrides the enabled state in the configuration file. Set to true to enable or false to disable. When unset, the enabled state in the configuration file prevails.

ALIBABA_CLOUD_SAFETY_POLICY_RULES

Overrides the rule list in the configuration file. The format is pattern=action, with multiple rules separated by commas. Valid values of action: allow, deny, and confirm. When set, the rules completely replace those in the configuration file (not merged). Set to an empty string to clear all rules. Example: *:Delete*=deny,ecs:Update*=confirm. When unset, the rules in the configuration file prevail.

ALIBABA_CLOUD_SAFETY_SKIP_CONFIRM

When set to true, skips the confirmation prompts of Safety Policy, which is equivalent to --yes. When unset, confirmation prompts are not skipped.