Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

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)

  1. Generate the new key and store it in your secret manager next to the current one:

    tappet keys generate
    
  2. 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.

  3. Re-wrap, from any machine with the current configuration and database access:

    export TAPPET_NEW_ENCRYPTION_KEY='<new key>'
    tappet keys rotate
    

    The 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-file instead of the environment variable if you prefer a file.

  4. Switch every process to the new key:

    TAPPET_ENCRYPTION_KEY='<new key>'
    TAPPET_ENCRYPTION_KEY_VERSION=<printed version>
    

    and restart all tappet serve and tappet worker processes. With Kubernetes, update the secret and run kubectl rollout restart deployment -l app.kubernetes.io/name=tappet.

  5. Verify: test a few credentials (tappet credentials test <id>) and check that recent executions succeed. The audit log records the rotation.

  6. 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

SecretHow
A credential’s own secret (API key, password)Edit the credential and paste the new value. OAuth2 credentials: reconnect.
API keysCreate a new key, update clients, revoke the old key.
TAPPET_OIDC_CLIENT_SECRETRotate in the identity provider, update the variable, restart API processes.
TAPPET_OIDC_COOKIE_KEYUpdate and restart API processes; sign-ins in progress at that moment must be restarted.
Database passwordUpdate the database user and TAPPET_DATABASE_URL, then restart.