Skip to content
🎉 Launch sale:50% off everything over $22 — automatically applied at checkout· ends Aug 2Shop the sale →
DevOps AI ToolKit
Newsletter
All prompts
AI for HashiCorp Vault Difficulty: Advanced ClaudeChatGPT

Vault Lease and TTL Tuning Prompt

Diagnose and fix HashiCorp Vault lease explosion — find which mounts and clients are generating leases, right-size default and max TTLs per mount, choose batch versus service tokens, and stop unbounded lease growth safely.

Target user
Platform engineers operating HashiCorp Vault in production
Difficulty
Advanced
Tools
Claude, ChatGPT

The prompt

You are a senior secrets-platform engineer who has debugged a Vault cluster brought to its knees by millions of leases, and who knows the cure is almost always a client re-authenticating in a loop rather than anything wrong with Vault.

I will provide:
- Symptoms: memory growth, slow unseal or startup, storage growth, latency on the leader, or an outright expiration-manager backlog
- Current lease counts if I have them, and which mounts they come from
- The mounts in use and their current TTL settings
- The clients: what authenticates, how often, and whether they renew or re-fetch
- My Vault version, edition, and storage backend

Your job:

1. **Quantify before changing anything.** Tell me exactly how to measure: `vault read sys/leases/count type=irrevocable`, walking `sys/leases/lookup/` to attribute leases per mount and path, and the telemetry that matters (`vault.expire.num_leases`, lease-revocation and renewal rates, and expiration-manager metrics). Get me to a table of lease count by mount and by auth role before we touch a TTL, because the fix depends entirely on which bucket dominates.

2. **Find the generator, not just the count.** Common causes to check in order: a client re-authenticating on every request or every loop iteration instead of caching its token; a sidecar or job creating a token per invocation; dynamic database or cloud credentials issued per connection rather than per process; PKI issuance with `no_store` unset at high volume; and orphan tokens that outlive their parents. For each, give the audit-log query shape or telemetry signal that confirms it.

3. **Fix the client behavior first.** Make the point plainly: shortening TTLs on a client that authenticates ten times a second reduces the steady-state count but does not fix the write amplification. The primary fix is caching the token and its lease, renewing rather than re-authenticating, and using Vault Agent's auto-auth and caching where the application can't be changed. Give the target pattern per client type.

4. **Right-size TTLs per mount.** Explain the hierarchy: the server config's `default_lease_ttl` and `max_lease_ttl`, per-mount overrides via `vault secrets tune -default-lease-ttl -max-lease-ttl` and `vault auth tune`, and the role-level `token_ttl`/`token_max_ttl` or engine role TTLs — with the rule that the effective TTL is the most restrictive of those in play. Note that Vault's default max lease TTL is 32 days, which is far longer than most workloads need. Produce a per-mount table with proposed values tied to actual session length.

5. **Choose the right token type.** Compare service tokens (persisted, leased, renewable, revocable, countable) against batch tokens (not persisted, not leased, no renewal, no lease tracking, cheap at high volume) and the periodic-token pattern for long-running agents that need indefinite renewal without a growing max TTL. Recommend batch tokens explicitly for high-rate, short-lived, non-renewing workloads — this is often the single highest-leverage change — and name the tradeoffs you accept: batch tokens can't be individually revoked the same way and don't support all operations.

6. **Clean up the existing backlog safely.** Give the revocation options in increasing order of risk: letting leases expire naturally, `vault lease revoke -prefix <path>` scoped to a specific mount, and the force/`sys/leases/revoke-force` path for irrevocable leases where the backend no longer accepts revocation. State the danger clearly — force revocation drops Vault's record without cleaning up the backing system, leaving orphaned database users or cloud IAM credentials that must then be reconciled manually. Require doing this in scoped batches during a low-traffic window, never as one bulk operation on a busy leader.

7. **Put guardrails in place.** Cover rate-limit quotas (`sys/quotas/rate-limit`, available in Community edition) scoped per mount or per client to stop a runaway client, and note that lease-count quotas (`sys/quotas/lease-count`) are Enterprise-only. Where lease-count quotas aren't available, define the alerting equivalent so a runaway is caught in minutes rather than at the next unseal.

8. **Define the monitoring baseline.** Alert on total lease count against a defined ceiling, on lease-count growth rate, on irrevocable lease count above zero, on renewal-failure rates, and on the top-N mounts by lease share so a new offender is visible immediately. Include a startup-time check, since a large lease population directly slows unseal and leader failover.

Output as: (a) the measurement commands and the lease-attribution table to fill in, (b) the identified generator with its confirming signal, (c) client-side fixes per workload type, (d) the per-mount TTL table with proposed values, (e) the token-type recommendation per workload, (f) a staged backlog-cleanup plan with risk notes, (g) quotas and alerting rules.

Do not raise a TTL to reduce renewal traffic — that trades a busy cluster for long-lived credentials. Never bulk-force-revoke without first understanding what backing-system objects will be orphaned, and always verify a scoped revocation in non-production first.

Run this prompt with AI

Test it, get an AI-improved version, or compare models — live in the Prompt Workspace. No copy-paste.

Why this prompt works

Lease explosion presents as a Vault problem — memory growth, a slow unseal, a struggling leader — and is almost always a client problem. The prompt refuses to let anyone touch a TTL before producing a lease count broken down by mount and auth role, because the correct fix is entirely determined by which bucket dominates. A backlog from PKI issuance with no_store unset has nothing in common with one from a sidecar minting a token per invocation, and a team that starts tuning default_lease_ttl globally without that table will change numbers for a week and fix nothing.

The insistence on client behaviour before TTLs is the load-bearing argument. Shortening a TTL on a client that authenticates ten times a second lowers the steady-state count while leaving the write amplification exactly as it was — the cluster is still doing the same work, just discarding it sooner. Naming the target pattern per client type, and pointing at Vault Agent’s auto-auth and caching where the application cannot be changed, addresses the cause. The token-type step is often the single highest-leverage change available: batch tokens are not persisted and not leased, so a high-rate, short-lived, non-renewing workload stops contributing to the problem entirely, provided you accept the stated tradeoffs on revocation.

Backlog cleanup is ordered by risk for a reason that only becomes obvious afterwards. Force revocation through sys/leases/revoke-force removes Vault’s record without touching the backing system, so every irrevocable database lease becomes an orphaned database user and every cloud credential lease becomes an IAM object nobody is tracking — you trade a lease count problem for a reconciliation problem with a security dimension. Requiring scoped batches in a low-traffic window, plus quotas and alerting afterwards, means the cleanup is survivable and the next runaway client is caught in minutes rather than at the next unseal.

Related prompts

More HashiCorp Vault prompts & error guides

Browse every HashiCorp Vault prompt and troubleshooting guide in one place.

Free download · 368-page PDF

Reading prompts? Get all 500 in one free PDF

500 battle-tested, copy-paste AI prompts engineered by a senior systems engineer — every one with fill-in placeholders and safety/back-out notes. Drop your email and it's yours.

  • 500 prompts: Linux · Kubernetes · Terraform · OpenStack · GitLab · Docker · Monitoring · Incident Response
  • Instant PDF download — yours free, forever
  • Plus one practical AI-workflow email a week (no spam)

Single opt-in · unsubscribe anytime · no spam.