HCVA0-003 practice question 34 of 35

What command would have created the token displayed below? $ vault token lookup hvs.nNeZ2I64ALCxuO7dqQEJGPrO Key: policies Value: [default dev]…

Full set: 285 questions
What command would have created the token displayed below? $ vault token lookup hvs.nNeZ2I64ALCxuO7dqQEJGPrO Key: policies Value: [default dev], num_uses: 5, ttl: 767h59m49s Key Value --- ----- accessor mfvaVMFgOcXHIeqlRasroSOn creation_time 1604610457 creation_ttl 768h display_name token entity_id n/a expire_time 2024-12-07T16:07:37.7540672-05:00 explicit_max_ttl 0s id hvs.nNeZ2I64ALCxuO7dqQEJGPrO issue_time 2024-11-05T16:07:37.7540672-05:00 meta num_uses 5 orphan false path auth/token/create policies [default dev] renewable true ttl 767h59m49s type service
Answer options
A: vault token create -policy=dev -use-limit=5 Correct answer
B: vault token create -policy=dev -ttl=768h
C: vault token create -policy=dev -policy=default -ttl=768h
D: vault token create -policy=dev
Correct Answer:
A. vault token create -policy=dev -use-limit=5
Explanation

The vault token lookup output displays three key attributes: policies: [default dev], numuses: 5, and creationttl: 768h. The command in option A, vault token create -policy=dev -use-limit=5, correctly generates a token with these properties.
1. Policies: The -policy=dev flag adds the dev policy. By default, Vault also attaches the default policy to all new tokens unless explicitly suppressed, matching the output.
2. Use Limit: The -use-limit=5 flag sets the token's number of uses to 5, matching numuses: 5.
3. TTL: The command does not specify a TTL. In this case, Vault applies the system's default TTL, which is 768 hours (32 days), matching the creationttl value.

Why Incorrect

B. This command does not set the use limit. The resulting token would have numuses: 0 (unlimited), which contradicts the required value of 5.
C. This command also omits the use limit, resulting in an unlimited-use token (numuses: 0), which is incorrect.
D. This command fails to set the required use limit of 5. The resulting token would have unlimited uses, which does not match the lookup output.

References

1. HashiCorp Vault Official Documentation, "Create a token - Command Options": The documentation for the vault token create command specifies the -policy and -use-limit flags. It also describes the -no-default-policy flag, which confirms that the default policy is attached automatically if the flag is not used.

Source: HashiCorp, "Vault CLI: token create", developer.hashicorp.com/vault/docs/commands/token/create. Accessed November 2023.

2. HashiCorp Vault Official Documentation, "Tokens - Token Policies": This document states, "By default, tokens are created with the default policy attached." This supports the reasoning that -policy=dev results in a token with both default and dev policies.

Source: HashiCorp, "Vault Concepts: Tokens", developer.hashicorp.com/vault/docs/concepts/tokens#token-policies. Accessed November 2023.

3. HashiCorp Vault Official Documentation, "Token Auth Method (API)": This documentation specifies the default configuration for the token authentication backend. It states, "The default TTL for tokens created against this backend is 32 days." (768 hours). This confirms that omitting the -ttl flag results in the creationttl shown in the output.

Source: HashiCorp, "Token Auth Method (API)", developer.hashicorp.com/vault/api-docs/auth/token#create-token. Accessed November 2023.

Scroll to Top