Skip to content

Vault — alert when a mount/secret engine disappeared

Someone ran `vault secrets disable` (debug or drift) — the pipeline reaches for DB creds and gets 404. Vault does not warn — for it this is a "normal admin action".

Recipe

bash
#!/usr/bin/env bash
# /etc/cron.d/vault-mount
# */15 * * * * root /opt/vault-mount.sh

export VAULT_ADDR=${VAULT_ADDR}
export VAULT_TOKEN=${VAULT_TOKEN}

# Comma-separated list of expected mount paths
EXPECTED=${EXPECTED:-database/,kv/,pki/}

LIVE=$(vault secrets list -format=json | jq -r 'keys[]')

MISSING=""
IFS=',' read -ra MOUNTS <<< "$EXPECTED"
for M in "${MOUNTS[@]}"; do
  if ! echo "$LIVE" | grep -qx "$M"; then
    MISSING="$MISSING$M,"
  fi
done

if [ -n "$MISSING" ]; then
  curl -fsS "$HEARTBEAT_URL" --data-urlencode "missing_mounts=$MISSING"
  exit 2
fi
echo "OK (all expected mounts present)"

Same thing in Enterno.io

Wrap in an Enterno heartbeat — learn about Vault config drift before it breaks a prod pipeline.

Set up API monitor → ← All recipes

Related recipes