Skip to main content
Vault key rotation: tenet-pii-enterprise rotate-key creates a new vault key pair, wraps its secret halves under your CMK and makes it current → you roll out both services → new writes use the new pair, and everything written under older keys still restores, because every ciphertext records the id of the key that wrote it.

When to use it

On your key-management schedule, after suspected exposure of a running host, or when your policy requires a new vault key per period. Two different things rotate:

How rotate-key works

  1. It generates the key pair in process and wraps the lookup key and the private key with kms:Encrypt under TENET_KMS_KEY_ARN, each under its own encryption context (tenet:purpose = pii-vault-lookup-key or pii-vault-private-key, plus tenet:key_id, tenet:deployment and tenet:public_key). It writes both wrapped blobs and the public key to the keyring, in the vault’s metadata table, under a new id like k20261106T091500Z-1a2b3c4d.
  2. Only then does it move the current pointer. Old key pairs are never deleted.
  3. It prints new current vault key pair: <key id> and exits 0. On any KMS or vault error it exits 2 with one line, tenet-pii-enterprise: error: <reason>, carrying the AWS error code — never key material.
It runs as the detect identity, with the detect grants: it needs kms:Encrypt for the two key purposes and never unwraps a private key, which the detect role is denied. It needs the detect service’s environment: TENET_KMS_KEY_ARN, TENET_VAULT_URL, TENET_DEPLOYMENT_ID, PGUSER, PGPASSWORD, AWS_REGION. Running replicas don’t pick up the new key. Each process pins its current key at launch. The new pair takes effect for a replica when it restarts — so finish with a rollout of both services.

Rotate the vault key pair and roll both services, with checks before and after.

Open in Cursor

Run it

A one-off Job from the detect Deployment’s own pod spec — same image, ServiceAccount (IRSA role) and environment — with different labels so no Lattice route or Service ever selects it:
The image’s entrypoint is tenet-pii-enterprise, so args: ["rotate-key"] runs the subcommand. The Job pod isn’t selected by the chart’s NetworkPolicies. If your cluster has a default-deny egress policy, allow it DNS, the AWS endpoint CIDRs on 443 and the database.

What changes, and what doesn’t

  • Old sessions keep restoring. The rehydrate service unwraps the private key of whichever key pair sealed a value; old pairs stay in the keyring. Nothing is re-encrypted.
  • Recurring values still dedupe. Lookups try the lookup key of every key the vault has used, so a value first seen under the old pair keeps its placeholder.
  • During the rolling restart, a replica that started before the rotation may issue a second placeholder for a value that a new replica already saw. Both placeholders restore correctly.
  • session_ref changes. Audit records key session_ref under the current lookup key, so one session’s records stop correlating across the rotation.

Gotchas

  • Rehydrate never creates keys. At startup it waits up to two minutes for the detect service to create the first key pair, then refuses to start: vault keyring is empty: start the detect role first or run `tenet-pii-enterprise rotate-key` .
  • The deployment id is checked on every rotation. A TENET_DEPLOYMENT_ID that differs from the one stamped in the vault is refused.
  • kms:Encrypt denied? The detect role needs kms:Encrypt for pii-vault-lookup-key and pii-vault-private-key with your deployment id pinned. Troubleshooting.
  • Don’t disable or schedule deletion of the CMK to “retire” an old key pair. Every key pair ever used is wrapped by it; losing it loses the vault and the audit objects.