Skip to content

003 · Domain 2: Vault policies · 13% of the exam

Task 2.5: Configure Vault policies using the UI and CLI

vault policy write, read, list, fmt and delete, the sys/policy endpoints, ACL policies in the UI, and checking a token with vault token capabilities.

Study it

  • Writing and checking policies with the CLI and the UI

    Lesson coming

Sample questions

Try each one before opening the answer. Every option is explained, with the HashiCorp documentation page that proves it.

Question 1 · choose 1

An operator wrote app.hcl, wants to upload it as the policy app-read, and then wants to check what an application's token can do on secret/data/app/config without sending a request to that path. Which pair of commands does this?

  1. Avault policy write app.hcl app-read, then vault token capabilities <token> secret/data/app/config
  2. Bvault policy fmt app.hcl, then vault policy read app-read
  3. Cvault policy write app-read app.hcl, then vault token capabilities <token> secret/data/app/config
  4. Dvault policy write app-read app.hcl, then vault token lookup <token>
Show the answer and why
  • Avault policy write app.hcl app-read, then vault token capabilities <token> secret/data/app/config

    Incorrect

    The name comes first and the file second, so this uploads a policy called app.hcl from a file named app-read.

  • Bvault policy fmt app.hcl, then vault policy read app-read

    Incorrect

    fmt only rewrites the file in canonical format and uploads nothing, and the second command does not report a token's access.

  • Cvault policy write app-read app.hcl, then vault token capabilities <token> secret/data/app/config

    Correct

    policy write takes the name, then the file; token capabilities lists the token's capabilities on a path.

  • Dvault policy write app-read app.hcl, then vault token lookup <token>

    Incorrect

    token lookup shows a token's properties and policy names, not its capabilities on a path.

Upload with vault policy write <name> <file>; check effective access with vault token capabilities, which accepts a token or uses the current one.

Question 2 · choose 1

An operator wants to see the names of every ACL policy stored in Vault. Which command shows them?

  1. Avault policy read
  2. Bvault token capabilities
  3. Cvault secrets list
  4. Dvault policy list
Show the answer and why
  • Avault policy read

    Incorrect

    This does not list the names of the stored policies.

  • Bvault token capabilities

    Incorrect

    This command is about one token, not the stored policies.

  • Cvault secrets list

    Incorrect

    This lists enabled secrets engines.

  • Dvault policy list

    Correct

    policy list prints the names of the installed policies.

vault policy wraps the sys/policy endpoints: list, read, write, delete and fmt.

Question 3 · choose 1

An operator wants to create an ACL policy in the Vault UI rather than the CLI. Where is that done, and how is the policy entered?

  1. AUnder Secrets engines, by writing the policy as a KV secret named after it
  2. BIn the UI's policy section: write the policy in the editor or upload an HCL file
  3. CNowhere, because the UI cannot create or edit policies
  4. DUnder the token's profile menu, by attaching capabilities to the current token
Show the answer and why
  • AUnder Secrets engines, by writing the policy as a KV secret named after it

    Incorrect

    Policies are not KV secrets; the UI has its own policy section.

  • BIn the UI's policy section: write the policy in the editor or upload an HCL file

    Correct

    The UI creates ACL policies in its own policy section, written directly or uploaded as an HCL file.

  • CNowhere, because the UI cannot create or edit policies

    Incorrect

    The UI supports creating policies directly or uploading HCL.

  • DUnder the token's profile menu, by attaching capabilities to the current token

    Incorrect

    Capabilities are granted through named policies, not set on a token in the UI.

Whichever interface is used, keep policies as code in version control so the UI is not the only copy.

Question 4 · choose 1

A developer wants to know exactly which policy the command vault kv put kv/secret value=x needs before asking an operator for access. What should the developer run?

  1. ARun it again with the -output-policy flag added
  2. Bvault policy fmt on the developer's current policy
  3. Cvault token lookup on the developer's token
  4. Dvault path-help kv/secret
Show the answer and why
  • ARun it again with the -output-policy flag added

    Correct

    -output-policy builds a minimal policy that grants what the command needs.

  • Bvault policy fmt on the developer's current policy

    Incorrect

    fmt only reformats a policy file.

  • Cvault token lookup on the developer's token

    Incorrect

    lookup shows token properties and policy names, not what a command needs.

  • Dvault path-help kv/secret

    Incorrect

    path-help explains an endpoint; it does not produce a policy.

-output-policy is the quickest way to draft least-privilege policies for CLI workflows.

Question 5 · choose 1

A pipeline must create the ACL policy app-read through the HTTP API from a policy file. Which request does it send?

  1. APOST /v1/sys/policies/acl with {"name": "app-read", "file": "./policies/app.hcl"}
  2. BPOST /v1/auth/token/policies/app-read with {"policy": "<HCL>"}
  3. CPOST /v1/sys/policies/acl/app-read with {"policy": "<the HCL as a string>"}
  4. DGET /v1/sys/policies/acl/app-read with the HCL as a query string
Show the answer and why
  • APOST /v1/sys/policies/acl with {"name": "app-read", "file": "./policies/app.hcl"}

    Incorrect

    The name is part of the path, and the server cannot read a client's file.

  • BPOST /v1/auth/token/policies/app-read with {"policy": "<HCL>"}

    Incorrect

    Policies are managed under sys/, not under the token method.

  • CPOST /v1/sys/policies/acl/app-read with {"policy": "<the HCL as a string>"}

    Correct

    The ACL policy endpoint takes the policy document as a string in the policy field.

  • DGET /v1/sys/policies/acl/app-read with the HCL as a query string

    Incorrect

    GET reads a policy; creating one is a write.

Escape the HCL into a JSON string first, for example with jq, then post it to sys/policies/acl/<name> or the older sys/policy/<name>.

Practice domain 2 →Practice all domains →