Tune the lease time-to-live (TTL)
The benefit of using Vault's dynamic secrets engines and auth methods is the ability to control how long the Vault-managed credentials (leases) remain valid. Often times, you generate short-lived credentials or tokens to reduce the risk of unauthorized attacks caused by leaked credentials or tokens. If you do not explicitly specify the time-to-live (TTL), Vault generates leases with TTL of 32 days by default.
For example, you enabled AppRole auth method at approle
, and create a role
named read-only
with max lease TTL of 120 days.
The command returns a warning about the TTL exceeding the mount's max TTL value.
Therefore, it will return a client token with TTL of 768 hours (32 days) instead of 120 days.
Max lease TTL on an auth mount
You cannot set the TTL for a role to go beyond the max lease TTL set on the
AppRole auth mount (approle
in this example). The default lease TTL and max
lease TTL are 32 days (768 hours).
Output:
If the desired max lease TTL is 120 days (2880 hours), update the max lease TTL on the mount.
The following command lists all available parameters that you can tune.
Now, the AppRole will generate a lease with token duration of 120 days (2880 hours).
Max lease TTL on a secrets mount
Similar to the AppRole auth method example, you can tune the max lease TTL on dynamic secrets.
For example, you enabled database secrets engine at mongodb
and create a role
named tester
with max lease TTL of 120 days (2880 hours). When you request a
database credential for the tester
role, it returns a warning, and its lease
duration is 32 days (768 hours) instead of 120 days.
To set the desired TTL on the role, tune the max lease TTL on the mongodb
mount.
Verify the configured max lease TTL available on the mount.
The following command lists all available parameters that you can tune.
When you introduce Vault into your existing system, the existing applications may not be able to handle short-lived leases. You can tune the default TTLs on each mount.
On the similar note, if the system default of 32 days is too long, you can tune the default TTL to be shorter to comply with your organization's policy.