Skip to main content
When you create a Vault token, you control its lifecycle and capabilities by specifying its type and duration. You can do this either directly via the CLI/API or by configuring an authentication method such as AppRole.

1. Creating Tokens via CLI

Use vault token create flags to define token type, TTL, and renewal behavior.

Common Flags

By default, Vault issues a non-renewable service token when no -type or -period is provided.

Example: Periodic Token (24h)

Output:
  • The -period="24h" flag makes the token periodic and renewable.
  • Omit -period to create a one-time service token.
  • Use -type="batch" with -ttl to generate a batch token.

2. Configuring Token Types in an Auth Method

You can predefine token types for roles within an auth method. This example uses AppRole Auth Method:
  1. Enable AppRole
  2. Create Roles with Specific Token Settings
    • Batch Token Role (TTL = 60s)
    • Periodic Token Role (Period = 72h)
Roles without an explicit token_type default to service tokens. Ensure you set token_type or period for the desired behavior.

Summary

You have two methods to control Vault token types and lifecycles:
  • CLI/API Flags:
    • -type for service or batch
    • -ttl for non-renewable duration
    • -period for renewable tokens
  • Auth Method Configuration:
    • Set token_type, token_ttl, and period in role definitions
By using these techniques, you can ensure Vault issues tokens that match your security and operational requirements.

Watch Video