1. Creating Tokens via CLI
Usevault 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)
- The
-period="24h"flag makes the token periodic and renewable. - Omit
-periodto create a one-time service token. - Use
-type="batch"with-ttlto 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:-
Enable AppRole
-
Create Roles with Specific Token Settings
-
Batch Token Role (TTL = 60s)
-
Periodic Token Role (Period = 72h)
-
Batch Token Role (TTL = 60s)
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:
-typefor service or batch-ttlfor non-renewable duration-periodfor renewable tokens
-
Auth Method Configuration:
- Set
token_type,token_ttl, andperiodin role definitions
- Set