HashiCorp Vault Associate (003) Question 197
Single answer7c Configure environment variablesA platform engineer is troubleshooting why Vault CLI commands fail on a build server. Running vault status returns an error indicating it cannot connect to https://127.0.0.1:8200, but the Vault server is actually available at https://vault.prod.example.com:8200. The engineer also wants CLI output in JSON so scripts can parse responses consistently. Which environment variable configuration will address both requirements without changing every command?
- A
Set
VAULT_ADDR=https://vault.prod.example.com:8200andVAULT_FORMAT=jsonin the shell environment - B
Set
VAULT_SERVER=https://vault.prod.example.com:8200andVAULT_OUTPUT=jsonin the shell environment - C
Set
VAULT_ADDR=https://vault.prod.example.com:8200andVAULT_TOKEN=jsonin the shell environment - D
Set
VAULT_HOST=vault.prod.example.comandVAULT_PORT=8200in the shell environment
Show answer and explanation
Correct answer: A
Explanation
The Vault CLI uses environment variables to avoid repeating connection and formatting flags on every command. By default, the CLI attempts to connect to https://127.0.0.1:8200 unless VAULT_ADDR is set or the -address flag is provided. For machine-readable output, VAULT_FORMAT=json is the correct environment variable. This is especially useful in CI/CD pipelines and build servers where consistent JSON output is needed for parsing. These behaviors are documented in the Vault CLI and environment variable documentation, and using environment variables in this way is a standard operational practice for Vault.
- A. Correct.
Correct.
VAULT_ADDRtells the Vault CLI which server address to use instead of the defaulthttps://127.0.0.1:8200.VAULT_FORMAT=jsonsets the CLI output format to JSON for commands that support formatted output, which is a common best practice for automation and scripting. - B. Incorrect.
Incorrect.
VAULT_SERVERandVAULT_OUTPUTare not standard Vault CLI environment variables. A candidate might choose this because the names sound intuitive, but Vault expectsVAULT_ADDRfor the server address andVAULT_FORMATfor output formatting. - C. Incorrect.
Incorrect.
VAULT_ADDRis valid, butVAULT_TOKENis used to provide an authentication token, not to control output format. This distractor targets confusion between commonly used Vault environment variables. - D. Incorrect.
Incorrect. Vault CLI does not use
VAULT_HOSTandVAULT_PORTas separate environment variables for connection settings. The CLI expects a full URL inVAULT_ADDR, including scheme, host, and port.