Schedule icon
Request icon
Script icon
Switch icon
Log icon
SlackIncomingWebhook icon
If icon

Audit HashiCorp Vault Transit Key Rotation and Version Staleness

Audit HashiCorp Vault Transit Engine encryption key rotation and version staleness with Kestra. Enforce cryptographic compliance with automated Slack alerts.

Categories
DataInfrastructure

In enterprise security architectures utilizing HashiCorp Vault's Transit Secrets Engine for cryptography-as-a-service, encryption keys protect sensitive workloads across payment gateways, PII databases, and authentication tokens. Industry standards (including PCI-DSS, SOC 2, and HIPAA) strictly mandate cryptographic key rotation within defined lifespans (typically 90 days). Neglected key rotation elevates blast radiuses in the event of compromised credentials and risks immediate compliance certification revocation.

This blueprint implements an automated Day 2 Operations governance gate that audits HashiCorp Vault Transit key metadata on a scheduled cadence. It inspects the creation timestamp of the latest key version, evaluates its age against organizational SLA thresholds, alerts security teams via Slack upon overdue staleness, and optionally executes an automated key rotation behind an explicit dry-run safety gate.

How it works

  1. schedule (io.kestra.plugin.core.trigger.Schedule) initiates the audit cycle every 6 hours (disabled by default for initial setup).
  2. probe_key_metadata (io.kestra.plugin.core.http.Request) invokes the Vault Transit API GET /v1/{mount}/keys/{key_name} using the configured VAULT_TOKEN to retrieve version history, minimum decryption version, and timestamp metadata.
  3. evaluate_key_age (io.kestra.plugin.scripts.python.Script) parses the JSON response, determines the age of the latest key version in days, and outputs a typed compliance verdict (COMPLIANT, ROTATION_OVERDUE, or PROBE_FAILED).
  4. route_by_compliance (io.kestra.plugin.core.flow.Switch) branches based on the calculated verdict.
  5. When compliant (COMPLIANT), log_compliant_status logs verified version and age metrics.
  6. When rotation is overdue (ROTATION_OVERDUE), alert_rotation_overdue dispatches an operational alert to Slack using io.kestra.plugin.slack.notifications.SlackIncomingWebhook. If auto_rotate is enabled and dry_run is false, rotate_transit_key generates a fresh key version automatically.
  7. log_audit_completion writes a final audit recap for execution tracking and lineage.
  8. The flow-level errors block intercepts unexpected connection failures or authentication errors and alerts Slack.

What you get

  • Automated cryptographic compliance monitoring preventing stale key certification failures.
  • Exact calculation of key version age against customizable organizational SLAs.
  • Optional zero-touch key rotation protected by a dual-safety gate (auto_rotate and dry_run).
  • Automated Slack incident notifications with key version context and remediation guidance.
  • Flow-level error alerting safeguarding security audit pipeline reliability.

Who it's for

  • Security Engineers and DevSecOps Teams maintaining enterprise HashiCorp Vault clusters.
  • Compliance and Risk Officers responsible for enforcing PCI-DSS and SOC 2 key rotation policies.
  • Platform and Cloud Engineers managing cryptographic infrastructure across microservices.

Why orchestrate this with Kestra

Tracking Vault key rotation with manual calendar reminders or isolated cron scripts creates operational blind spots, lacks audit lineage, and increases the risk of unhandled secret rotation failures. Kestra provides a declarative workflow engine with centralized secret management, conditional flow branching, execution history, and native Slack alerting without writing or maintaining custom monitoring daemons.

Prerequisites

  • A running HashiCorp Vault instance (v1.12+ or Vault Cloud HCP) with the Transit Secrets Engine enabled (vault secrets enable transit).
  • An existing Transit encryption key (e.g. payment-encryption-key).
  • A Vault token with read and update permissions on the transit key path (sys/mounts, transit/keys/*).
  • A Slack Incoming Webhook URL configured in Kestra secrets.

Local Container Setup

To run HashiCorp Vault locally in development mode while avoiding host port 8080 conflicts:

docker run -d --name vault-dev -p 8200:8200 -e 'VAULT_DEV_ROOT_TOKEN_ID=root' hashicorp/vault:latest

Initialize a transit key in the dev container:

docker exec -it vault-dev vault secrets enable transit
docker exec -it vault-dev vault write -f transit/keys/payment-encryption-key

If Kestra is running inside a Docker network, connect the Vault container to Kestra network:

docker network ls
docker network connect YOUR_KESTRA_NETWORK vault-dev

Secrets

  • VAULT_TOKEN: Vault administrative or service token with read permissions on the Transit engine.
  • SLACK_WEBHOOK: Incoming Webhook URL for Slack alerting.

Note for Kestra Open-Source (OSS): Secrets are provided as base64-encoded environment variables formatted as SECRET_<NAME> on the Kestra server or worker environment.

Inputs

Name Type Default Allowed Values Description
vault_addr STRING "http://localhost:8200" HTTP/HTTPS URL Base endpoint URL of Vault server
key_name STRING "payment-encryption-key" Valid key name Target Transit encryption key name
transit_mount STRING "transit" Valid mount path Transit Secrets Engine mount path
max_key_age_days INT 90 Positive integer Maximum key version age before alert
auto_rotate SELECT "false" "true", "false" Automated key rotation toggle
dry_run SELECT "true" "true", "false" Dry run simulation flag

Outputs

  • {{ outputs.evaluate_key_age.vars.verdict }}: Compliance verdict (COMPLIANT, ROTATION_OVERDUE, PROBE_FAILED).
  • {{ outputs.evaluate_key_age.vars.latest_version }}: Current active primary version of the Transit key.
  • {{ outputs.evaluate_key_age.vars.age_days }}: Calculated age in days of the latest key version.
  • {{ outputs.evaluate_key_age.vars.key_type }}: Cryptographic algorithm and key type (e.g. aes256-gcm96).

Quick start

  1. Configure VAULT_TOKEN and SLACK_WEBHOOK in your Kestra namespace secrets.
  2. Import this blueprint into your Kestra instance.
  3. Run a manual execution with default inputs against your local or development Vault instance.
  4. Confirm execution logs show COMPLIANT with the key version and age printed.
  5. Enable the schedule trigger to audit key rotation periodically.

How to extend

  • Add automated PagerDuty or Opsgenie escalations when a key exceeds 120 days without rotation.
  • Extend the Python script to audit all Transit keys by querying LIST /v1/{mount}/keys.
  • Chain a downstream re-encryption workflow (POST /v1/{mount}/rewrap/{key_name}) to update stored ciphertexts after key rotation.

Pitfalls

  • Token Capabilities: Ensure the configured VAULT_TOKEN policy grants read capability on transit/keys/{key_name} and update on transit/keys/{key_name}/rotate.
  • Port Conflicts: Ensure Vault port 8200 does not collide with other local development services.
  • Dry Run Protection: Automated rotation only executes when both auto_rotate: "true" AND dry_run: "false" are explicitly supplied.

Links

See How

New to Kestra?

Use blueprints to kickstart your first workflows.