HashiCorp Certified: Vault Associate (002) — Question 52
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?
Answer options
- A. Environment variables take precedence over flags
- B. VAULT_CLUSTER_ADDR needs to be provided
- C. Flags take precedence over environment variables
- D. Vault listener is misconfigured
Correct answer: C
Explanation
The second attempt was successful because command line flags, such as the -address flag, take precedence over environment variables like VAULT_ADDR. This means that despite having VAULT_ADDR set to 'https://vaultcluster2.acxe.corp:8200', the address specified in the command line was used, allowing the command to complete successfully. The other options are incorrect because they misrepresent the priority of flags versus environment variables.