Key rotation
Credentials are protected by envelope encryption (see Credentials vault): each credential’s data key (DEK) is wrapped by the key-encryption key (KEK). Rotating the KEK re-wraps every DEK under a new key. Credential ciphertexts are not re-encrypted, so rotation takes seconds even with thousands of credentials.
Rotate when:
- someone who had access to the key leaves,
- the key may have been exposed (logs, a leaked environment dump, a lost laptop),
- your policy requires periodic rotation.
Procedure (key in TAPPET_ENCRYPTION_KEY)
-
Generate the new key and store it in your secret manager next to the current one:
tappet keys generate -
Plan a short window. Processes still running with the old key cannot unwrap data keys that were already re-wrapped under the new one, so executions that need credentials can fail between step 3 and step 4. Either scale workers to zero for the duration, or run steps 3 and 4 back to back.
-
Re-wrap, from any machine with the current configuration and database access:
export TAPPET_NEW_ENCRYPTION_KEY='<new key>' tappet keys rotateThe command re-wraps every DEK under the next key version (current version + 1, or
--new-version N) and prints the version it used. It can be interrupted and re-run safely. Use--new-key-fileinstead of the environment variable if you prefer a file. -
Switch every process to the new key:
TAPPET_ENCRYPTION_KEY='<new key>' TAPPET_ENCRYPTION_KEY_VERSION=<printed version>and restart all
tappet serveandtappet workerprocesses. With Kubernetes, update the secret and runkubectl rollout restart deployment -l app.kubernetes.io/name=tappet. -
Verify: test a few credentials (
tappet credentials test <id>) and check that recent executions succeed. The audit log records the rotation. -
Retire the old key after your backup retention window has passed. Backups taken before the rotation are wrapped under the old key and need it to restore.
Development key file
When the key lives in ${TAPPET_DATA}/encryption.key (development mode), tappet keys rotate
generates the new key itself, writes it next to the data before re-wrapping, replaces the key file
when done and keeps the previous key file as a backup. Restart running processes afterwards.
External key managers
With HashiCorp Vault Transit or AWS KMS, rotate the key inside the key manager (both keep previous
versions able to decrypt), then run tappet keys rotate to re-wrap all DEKs under the newest
version. No Tappet configuration change is needed.
Rotating other secrets
| Secret | How |
|---|---|
| A credential’s own secret (API key, password) | Edit the credential and paste the new value. OAuth2 credentials: reconnect. |
| API keys | Create a new key, update clients, revoke the old key. |
TAPPET_OIDC_CLIENT_SECRET | Rotate in the identity provider, update the variable, restart API processes. |
TAPPET_OIDC_COOKIE_KEY | Update and restart API processes; sign-ins in progress at that moment must be restarted. |
| Database password | Update the database user and TAPPET_DATABASE_URL, then restart. |