Security, cost and GPUs
Rotating secrets without an outage
Rotate a secret by letting the old and new values work together for a while, so no consumer breaks. Dual credentials, short-lived certificates and fresh reads make rotation routine.
Rotation replaces a secret with a new value and retires the old one. It fails when every consumer has to switch at the same instant. The fix is to let the old and new values work together for a short window. Then consumers move over one by one.
Concept
Before you start. Read the secret lifecycle, especially the rotate and revoke stages.
The big idea
Think of changing the locks on a house. You cut the new key, and for a day both keys open the door. Each family member switches to the new key. Once everyone has switched, you remove the old lock.
Where the analogy breaks: you must know who holds a key. For secrets, that means an inventory with an owner and a maximum age for each one. An unknown consumer is the one that breaks at the cutover.
Walking through a Postgres rotation
This rotation takes about 15 minutes, using a dual-credential setup.
t=0 Set password B for the database user. Accept A and B for now,
using a dual-user setup or app-side logic.
t=1-10 Roll the pods. Each pod fetches the latest secret on boot.
t=10 Check the auth log. Confirm nothing logs in with password A.
t=15 Revoke A. Mark the rotation as done.Step t=10 is the signal that makes step t=15 safe. You do not revoke on a timer alone.
Patterns that avoid pages
- Dual credentials. The database accepts two passwords. Apps move to the new one, then the old one is revoked.
- Token minting. Apps never see a shared password. Vault or IAM issues each instance its own credential with a time limit.
- Blue-green secrets. New deployments get the new secret through External Secrets. Old replicas drain.
- Short-lived certificates. Certificates last hours or days, from Vault PKI or SPIFFE. Revocation then mostly means waiting for expiry.
Common mistakes
- Caching a password forever in memory. After rotation, every cached copy fails at once. Refresh on an auth failure, or before the time limit.
- Rotating without knowing consumers. Without an owner tag, you find the consumers by breaking them.
- Revoking the old value too early. Check the auth log first.
Check yourself
- Why does dual-credential rotation avoid downtime? Answer: both old and new values work during the window, so consumers can switch one at a time.
- What tells you it is safe to revoke the old password? Answer: the auth log shows no logins with the old value for the whole window.
Key takeaways
- Let the old and new values work together during a window.
- Apps must refresh secrets. Caching them forever turns rotation into an outage.
- Short-lived certificates make rotation mostly a matter of waiting.
- Next, leak response covers what to do when a secret escapes anyway.
Further learning
Rotate AWS Secrets Manager secretsLearn how to set up automatic rotation for secrets.docs.aws.amazon.com Alternating users rotation (AWS Secrets Manager)Learn how to set up automatic rotation for database credentials.docs.aws.amazon.com Dynamic secrets for database credentials (HashiCorp Vault)Dynamically generate, manage, and revoke database credentials that meet your organization's password policy requirements.Dynamic secrets for database credential management | Vault | HashiCorp Developer
SPIFFE conceptsSPIFFE Concepts | SPIFFEspiffe.ioRelated
Secrets management and encryption
Keeping credentials out of code and data safe at rest and in transit with KMS, Vault and envelope encryption — plus how to catch leaks before they become incidents.
What a secret is and its lifecycle
A secret is any credential that grants access. Each one moves through create, distribute, use, rotate, revoke and audit, and leaks happen when that path breaks.
Detecting and responding to leaked secrets
Scan for leaked secrets at commit time, in CI, across git history and at runtime. When one leaks, rotate first and clean history second.