nerdexam
HashiCorp

VAULT-ASSOCIATE-002 · Question #96

You manage two Vault dusters: "vaultduster1.acme.corp" and "vaultduster2.acme.corp". You want to write a secret to the first Vaultcluster vaultcluster1.acme.corp and run vault kv put secret/foo…

The correct answer is C. Flags take precedence over environment variables. The second attempt succeeded because command-line flags, specifically the -address flag, take precedence over environment variables like VAULT_ADDR when specifying the target Vault server.

Submitted by chen.hong· Apr 18, 2026Operate Vault

Question

You manage two Vault dusters: "vaultduster1.acme.corp" and "vaultduster2.acme.corp". You want to write a secret to the first Vaultcluster vaultcluster1.acme.corp and run vault kv put secret/foo value='bar'. The command times out and the error references the Vault cluster, "vaultcluster2.acme.corp". You run the command again with the following address flag: vault kv put -address='https://vaultcluster1.acme.corp' secret/foo value='bar' The command completes successfully. You find that the terminal session defines the environment variable VAULT_ADDR='https://vaultcluster2.acxe.corp:8200' Why was the second attempt successful?

Options

  • AEnvironment variables take precedence over flags
  • BVAULT_CLUSTER_ADDR needs to be provided
  • CFlags take precedence over environment variables
  • DVault listener is misconfigured

How the community answered

(51 responses)
  • A
    6% (3)
  • B
    2% (1)
  • C
    88% (45)
  • D
    4% (2)

Why each option

The second attempt succeeded because command-line flags, specifically the `-address` flag, take precedence over environment variables like `VAULT_ADDR` when specifying the target Vault server.

AEnvironment variables take precedence over flags

This statement is incorrect; command-line flags override environment variables, not the other way around, in the Vault CLI's order of precedence.

BVAULT_CLUSTER_ADDR needs to be provided

`VAULT_CLUSTER_ADDR` is not a standard environment variable used by the Vault CLI for specifying the target Vault address; the correct variable is `VAULT_ADDR`.

CFlags take precedence over environment variablesCorrect

When both an environment variable like `VAULT_ADDR` and a command-line flag such as `-address` are present in a Vault CLI command, the command-line flag is always given higher priority. This design allows users to override default configurations set by environment variables for specific commands without changing their environment permanently.

DVault listener is misconfigured

The Vault listener was likely correctly configured for `vaultcluster1.acme.corp`, but the initial command targeted the wrong cluster due to the `VAULT_ADDR` environment variable being overridden by the flag in the second attempt.

Concept tested: Vault CLI environment variables and flags precedence

Source: https://developer.hashicorp.com/vault/docs/commands#environment-variables

Topics

#Vault CLI#Configuration precedence#VAULT_ADDR#Command-line flags

Community Discussion

No community discussion yet for this question.

Full VAULT-ASSOCIATE-002 Practice