Skip to content

003 · Domain 3: Vault tokens · 15% of the exam

Task 3.6: Describe how to create tokens based on need

vault token create flags and token roles: policies, TTLs, periods, use limits, batch type, orphans, and tokens for one-off or long-running jobs.

Study it

  • Creating tokens: flags, token roles and use limits

    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

A bootstrap script needs a token that works for exactly two requests and is then useless, even if its TTL has not run out. Which command creates it?

  1. Avault token create -ttl=2m -policy=bootstrap
  2. Bvault token create -type=batch -policy=bootstrap
  3. Cvault token create -use-limit=2 -policy=bootstrap
  4. Dvault token create -renewable=false -policy=bootstrap
Show the answer and why
  • Avault token create -ttl=2m -policy=bootstrap

    Incorrect

    A TTL limits time, not the number of requests.

  • Bvault token create -type=batch -policy=bootstrap

    Incorrect

    A batch token works until its TTL ends, however many requests it makes.

  • Cvault token create -use-limit=2 -policy=bootstrap

    Correct

    -use-limit sets how many times the token can be used before it is revoked.

  • Dvault token create -renewable=false -policy=bootstrap

    Incorrect

    This only prevents renewal; the token works for unlimited requests until its TTL ends.

Use limits suit one-off tokens; combine them with a short TTL so an unused token does not linger.

Question 2 · choose 1

A CI controller's token carries only the ci-controller policy and has no sudo. For every build, the controller must create a token that carries the ci-build policy, which its own token does not have, and no build token may live longer than 1 hour. Which approach works?

  1. ARun vault token create -policy=ci-build -explicit-max-ttl=1h with the controller's token
  2. BRun vault token create -policy=ci-build -ttl=1h -orphan with the controller's token
  3. CDefine a token role with allowed_policies=ci-build and token_explicit_max_ttl=1h, and create build tokens against it
  4. DDefine a token role with allowed_policies=ci-build and token_ttl=1h, and create build tokens against it
Show the answer and why
  • ARun vault token create -policy=ci-build -explicit-max-ttl=1h with the controller's token

    Incorrect

    Without a role, a new token may only carry policies its creator already has, unless the creator is root or holds sudo.

  • BRun vault token create -policy=ci-build -ttl=1h -orphan with the controller's token

    Incorrect

    Creating an orphan this way needs sudo, and the policy is still outside the creator's set.

  • CDefine a token role with allowed_policies=ci-build and token_explicit_max_ttl=1h, and create build tokens against it

    Correct

    Role-based creation allows the policies the role lists instead of only the caller's.

  • DDefine a token role with allowed_policies=ci-build and token_ttl=1h, and create build tokens against it

    Incorrect

    token_ttl is only the initial TTL; renewable tokens can be renewed up to the mount or system max, far beyond an hour.

Token roles let a less privileged creator issue tokens with a fixed set of policies and limits, without sudo.

Question 3 · choose 1

A build controller creates tokens against the token role builds. Its own token carries the policies ci-read, ci-write and prod-admin. Build tokens may carry any of the controller's policies except prod-admin. Which role setting enforces this?

  1. Aallowed_policies=prod-admin
  2. Btoken_no_default_policy=true
  3. Cdisallowed_policies=prod-admin
  4. Drenewable=false
Show the answer and why
  • Aallowed_policies=prod-admin

    Incorrect

    This would let tokens from the role carry only prod-admin, the opposite of the goal.

  • Btoken_no_default_policy=true

    Incorrect

    This only keeps the default policy off the tokens.

  • Cdisallowed_policies=prod-admin

    Correct

    Token creation through the role then fails whenever prod-admin is requested, while other policies follow the normal rules.

  • Drenewable=false

    Incorrect

    This only stops renewal past the initial TTL; it does not restrict policies.

A disallowed list blocks the named policies while the creator can still hand out the rest of its own policies through the role.

Question 4 · choose 1

A developer without sudo runs vault token create -period=24h -policy=app and is denied. Why?

  1. ASetting a period there needs root or sudo
  2. B-period accepts only values of 1 hour or less without sudo
  3. CPeriodic tokens can only be batch tokens
  4. DThe app policy must contain the period setting
Show the answer and why
  • ASetting a period there needs root or sudo

    Correct

    Periodic tokens through the create endpoint need root or sudo; token roles are the other route.

  • B-period accepts only values of 1 hour or less without sudo

    Incorrect

    There is no such limit; the issue is permission.

  • CPeriodic tokens can only be batch tokens

    Incorrect

    Batch tokens cannot be periodic.

  • DThe app policy must contain the period setting

    Incorrect

    Policies do not carry token periods.

Grant periodic tokens through a token role with token_period, or let a sudo holder create them.

Question 5 · choose 1

A token role named deploy exists. Which command creates a token against it?

  1. Avault token create -policy=deploy
  2. Bvault token create -role=deploy
  3. Cvault write auth/token/roles/deploy
  4. Dvault token create -display-name=deploy
Show the answer and why
  • Avault token create -policy=deploy

    Incorrect

    This attaches a policy named deploy; it does not use the role.

  • Bvault token create -role=deploy

    Correct

    -role names the token role, and the caller needs permission for auth/token/create/deploy.

  • Cvault write auth/token/roles/deploy

    Incorrect

    Writing to roles/ creates or updates the role itself.

  • Dvault token create -display-name=deploy

    Incorrect

    A display name labels the token; it does not choose a role.

Token roles bundle settings such as allowed policies, period and orphan; tokens are created against them with -role.

Question 6 · choose 1

An operator whose token carries the policies default, ops and audit runs vault token create with no -policy flag and no role. Which policies does the new token carry?

  1. AOnly default, the policy every new token receives
  2. BNone; the command fails until a -policy flag is given
  3. CThe root policy, since no restriction was given
  4. DThe operator's own policies: default, ops and audit
Show the answer and why
  • AOnly default, the policy every new token receives

    Incorrect

    default is added to new tokens, but without -policy the token also gets its creator's other policies.

  • BNone; the command fails until a -policy flag is given

    Incorrect

    -policy is optional; without it the token inherits its creator's policies.

  • CThe root policy, since no restriction was given

    Incorrect

    A new token gets root only when its creator is itself a root token; leaving out -policy widens nothing.

  • DThe operator's own policies: default, ops and audit

    Correct

    A created token inherits all policies of the authenticated token unless a list of policies is given.

Name the policies explicitly when creating tokens for others, so they do not inherit everything their creator can do.

Practice domain 3 →Practice all domains →