EnvironmentVariables.md

May 26, 2026 · View on GitHub

← Overview | Environment Variables(中文)


Environment Variables

This page consolidates all credential-related environment variables supported by the SDK, for easy deployment / CI injection. Other categories (Region, TLS, etc.) can be appended here as new sections later.

How to Set

Linux / macOS

Temporary (current shell only):

export VOLCENGINE_ACCESS_KEY=your-ak
export VOLCENGINE_SECRET_KEY=your-sk
export VOLCENGINE_SESSION_TOKEN=your-session-token

To persist, put the export lines in ~/.bashrc, ~/.zshrc, or your shell's startup file.

Verify with echo $VOLCENGINE_ACCESS_KEY.

Windows

Command line (run as Administrator):

setx VOLCENGINE_ACCESS_KEY your-ak /M
setx VOLCENGINE_SECRET_KEY your-sk /M
setx VOLCENGINE_SESSION_TOKEN your-session-token /M

/M sets system-level variables; omit /M for user-level.

GUI: This PC → right-click → PropertiesAdvanced system settingsEnvironment VariablesNew.

Verify: open a new command prompt and run echo %VOLCENGINE_ACCESS_KEY%.

Credentials

Basic AK/SK/Token

VariableDescriptionRequired
VOLCENGINE_ACCESS_KEYAccess Key
VOLCENGINE_SECRET_KEYSecret Key
VOLCENGINE_SESSION_TOKENSTS session token

OIDC (AssumeRoleWithOIDC)

VariableDescriptionRequired
VOLCENGINE_OIDC_ROLE_TRNOIDC role TRN
VOLCENGINE_OIDC_TOKEN_FILEOIDC token file path
VOLCENGINE_OIDC_ROLE_SESSION_NAMESession name
VOLCENGINE_OIDC_ROLE_POLICYSession policy JSON
VOLCENGINE_OIDC_STS_ENDPOINTSTS endpoint host

ECS IMDS

VariableDescription
VOLCENGINE_ECS_METADATAECS instance role name; if unset, auto-discovered from IMDS
VOLCENGINE_ECS_METADATA_DISABLEDSet to true to disable IMDS credential retrieval

CLI Config File

VariableDescription
VOLCENGINE_CLI_CONFIG_FILEConfig file path; defaults to ~/.volcengine/config.json
VOLCENGINE_PROFILEProfile name to use
VOLCENGINE_LOGIN_CACHE_DIRECTORYOptional console-login cache directory; defaults to <config dir>/login/cache

Legacy Compatibility Variables (VOLCSTACK_*)

Early SDKs used the VOLCSTACK_* prefix. When the corresponding VOLCENGINE_* variable is unset, the following are used as fallbacks. New code should use VOLCENGINE_* only.

VariableEquivalent VOLCENGINE_*GoJavaPHPPython
VOLCSTACK_ACCESS_KEY_ID / VOLCSTACK_ACCESS_KEYVOLCENGINE_ACCESS_KEY
VOLCSTACK_SECRET_ACCESS_KEY / VOLCSTACK_SECRET_KEYVOLCENGINE_SECRET_KEY
VOLCSTACK_SESSION_TOKENVOLCENGINE_SESSION_TOKEN
VOLCSTACK_PROFILEVOLCENGINE_PROFILE

The Go SDK has a few additional legacy VOLCSTACK_* variables (shared-credentials file path, legacy AssumeRole settings, etc.) that are not listed here. Please migrate to the VOLCENGINE_* interfaces documented on this page.

Default Credential Chain

When no credentials are explicitly configured, the Go SDK tries the following providers in order; the first one that succeeds is used:

  1. Environment Variable Provider (VOLCENGINE_ACCESS_KEY / VOLCENGINE_SECRET_KEY[/VOLCENGINE_SESSION_TOKEN])
  2. OIDC Provider (reads VOLCENGINE_OIDC_*)
  3. CLI Config Provider (~/.volcengine/config.json)
  4. ECS IMDS Provider

Priority Summary

ItemPriority (high → low)
CLI config file pathconstructor arg > VOLCENGINE_CLI_CONFIG_FILE > ~/.volcengine/config.json
Profileconstructor arg > VOLCENGINE_PROFILE > VOLCSTACK_PROFILE (Go/PHP only) > current field in config > default
ECS role nameconstructor arg > VOLCENGINE_ECS_METADATA > IMDS auto-discovery

See Also


← Overview | Environment Variables(中文)