Schedule icon
Webhook icon
Assert icon
Request icon
Script icon
Set icon
If icon
SlackIncomingWebhook icon
Fail icon
Log icon
OutputValues icon

HashiCorp Vault Dynamic Secret Lease Expiry & Renewal Guard

Enumerate HashiCorp Vault dynamic secret leases, extend renewable credentials before expiration, detect orphaned leases, and log audit trails in Kestra KV.

Categories
CloudInfrastructure

Dynamic database credentials and cloud IAM roles generated by HashiCorp Vault prevent credential reuse and limit blast radiuses. However, long-running services frequently suffer production outages when dynamic leases reach their time-to-live (TTL) without automated renewal, or when non-renewable credentials hit their hard max TTL without an application restart.

This blueprint provides an enterprise guard that scans Vault dynamic secret lease hierarchies, verifies cluster seal status, extends renewable leases before expiration, detects orphaned credentials requiring application restarts, records historical audit trails in Kestra KV, and alerts operations teams on Slack.

How it works

  1. Pre-flight Health Gate: Validates input parameters and queries GET /v1/sys/health to ensure the HashiCorp Vault cluster is initialized, unsealed, and operational.
  2. Recursive Lease Enumeration: Scans configurable lease prefixes (e.g., database/creds, aws/creds) using Vault's LIST /v1/sys/leases/lookup/<prefix> API to locate all active dynamic leases.
  3. TTL Inspection & Auto-Renewal: Queries PUT /v1/sys/leases/lookup for each discovered lease ID. If a lease's remaining TTL falls below expiry_threshold_hours and renewable is true, an advisory extension is requested via PUT /v1/sys/leases/renew with renewal_increment_seconds.
  4. Orphaned Lease Detection: Leases with remaining TTL below the threshold where renewable is false are flagged as critical orphans. These represent credentials that have reached their configured engine max_ttl or were created non-renewable, requiring application restart or role re-authentication.
  5. Compliance Audit Trail in KV: Stores an atomic evaluation manifest in Kestra's namespace Key-Value store with key vault_dynamic_lease_guard_audit, including scan timestamps, counts, and per-lease details.
  6. Actionable Slack Alerts: Dispatches rich Slack attachments detailing renewed leases, healthy counts, and prioritized warnings directing engineers to applications at risk of credential revocation.
  7. Policy Enforcement Gate: Optionally triggers a pipeline failure if orphaned non-renewable leases are discovered and fail_on_orphaned_breach is enabled.

What you get

  • Automated renewal of expiring dynamic database and cloud credentials before service disruption.
  • Early warning detection of non-renewable orphaned leases approaching hard expiration.
  • Persistent audit trail in Kestra KV tracking lease renewals and expiration countdowns.
  • Multi-engine visibility across PostgreSQL, MySQL, AWS STS, and cloud identity dynamic secrets.
  • Emergency notifications on Slack with actionable remediation steps.

Who it's for

  • Platform Engineers and SREs operating production HashiCorp Vault clusters.
  • Security Operations (SecOps) teams enforcing dynamic secret lifecycle policies.
  • Database Administrators managing automated credential rotation for stateful services.

Why orchestrate this with Kestra

Managing lease renewal loops inside client applications increases microservice code complexity and creates failure points when processes restart. Centralizing lease lifecycle management in Kestra provides declarative visibility, scheduled verification runs, centralized secret protection, historical audit state in KV, and incident escalation without writing bespoke daemon cron jobs.

Prerequisites

  • A running HashiCorp Vault cluster (open-source or Enterprise) with dynamic secret engines enabled (e.g., Database, AWS, Azure, GCP).
  • A Vault token with read and update capabilities on sys/leases/* and read on sys/health.
  • A Slack Incoming Webhook URL for operational notifications.

Secrets

  • VAULT_TOKEN: Vault authentication token with permissions to list, lookup, and renew leases under /sys/leases/*.
  • SLACK_WEBHOOK_URL: Slack Incoming Webhook URL to deliver lease guard digests and alerts.
  • VAULT_GUARD_WEBHOOK_KEY: Secret authentication key protecting the on-demand webhook trigger.

Quick start

  1. Configure VAULT_TOKEN, SLACK_WEBHOOK_URL, and VAULT_GUARD_WEBHOOK_KEY in your Kestra namespace secrets.
  2. Import this blueprint and set vault_address to your Vault cluster endpoint (e.g., https://vault.internal.example.com:8200).
  3. Execute the workflow manually to perform a dry scan of active dynamic leases.
  4. Enable the periodic_lease_audit trigger to establish automated 4-hour lease lifecycle guard scans.

How to extend

  • Automated Service Restarts: Connect the orphaned lease branch to a Kubernetes plugin task (io.kestra.plugin.kubernetes.pod.Delete or rollout restart) to recycle pods holding unrenewable credentials before expiration.
  • PagerDuty Integration: Add an on-call escalation task to notify database administrators if a critical production database role lease cannot be renewed.
  • Custom Mount Paths: Add cloud identity prefixes like gcp/key or azure/creds to inputs.lease_prefixes to encompass multi-cloud dynamic secrets.

Links

See How

New to Kestra?

Use blueprints to kickstart your first workflows.