Lion Cipher Lab

Rotate a database password with zero downtime: build AWS Secrets Manager's four-step rotation offline and test how it fails

Why it matters

Almost every application holds at least one password it uses to log in to its database. That password is a long-lived secret: it sits in config, in the secrets manager, in the memory of every running server, and sometimes in a log line or a backup. If it leaks and never changes, whoever has it can log in forever. Rotation means changing that password on a schedule, so a leaked copy has an expiry date. The hard part is doing it without breaking the app, because for a few seconds the database and the apps disagree about what the password is. AWS Secrets Manager solves this with a four-step…

What you'll learn

Steps in this lab

  1. What rotation is, and the one thing it buys you
  2. Set up: a terminal, Python, and an empty folder
  3. The contract: a secret is a set of versions, and labels say which is which
  4. The four steps, and why they come in this order
  5. Build the machinery: rotlib.py
  6. Write experiment.py and watch the labels move
  7. Measure the gap: single user vs alternating users
  8. Failure 1: the function crashes right after setSecret
  9. Failure 2: testSecret fails. What did the abort actually protect?
  10. Size the client cache against the rotation interval
  11. Watch for rotation failures: a failed rotation is a silent ticking clock
  12. Better than rotating: let the service rotate it, or have no stored password at all
  13. What rotation does NOT fix, and how a pro runs it

Open the full interactive lab →