Skip to content

Cloud

Secrets Management

Storing and fetching a secret are both O(1) lookups. The real value isn't speed. It's reducing exposure: fewer places a secret sits in plain text, and a fast, controlled way to rotate one out.

The idea, in plain English

Picture a workplace where passwords used to live on sticky notes stuck to monitors. Anyone walking by could read them, and when a password changed, someone had to remember to peel off the old note and write a new one. A secrets manager replaces every sticky note with a vault. Passwords, API keys, and other 'secrets' — sensitive values your app needs but people shouldn't casually see — live inside it instead of sitting in code or config files in plain view. The vault decides who's allowed to open it, and it hands out the current value only to those with permission. It also keeps a version history, so you can rotate a secret — replace it with a fresh one — without instantly breaking whatever was still using the old one.

How it works

  1. 1Store each secret under a name, along with the list of roles allowed to read it. This is like storing something in the vault along with the list of people who know the combination.
  2. 2When something asks for a secret, first check whether its role is on the allowed list. If there's no match, give no value: reject the request before you ever touch the vault contents.
  3. 3If the role is allowed, hand back the current, latest version by default. Never print or log the raw secret in full. Mask it, showing just enough to confirm which secret it is.
  4. 4To rotate a secret, store a new value under the same name as a new version. Keep the old version around, rather than deleting it right away, so anything still using the old value doesn't break immediately.

When you'd use it

Use this any time your code needs a password, API key, certificate, or token to talk to something else. Secrets management keeps those values out of source code and config files, where they'd otherwise get stuck in history forever. It controls exactly who and what can read them, and it turns rotating a leaked or expiring secret into a routine task instead of a scramble.

Common beginner mistakes

  • Hardcoding a secret directly in source code 'just for now.' 'For now' becomes forever the moment it's committed, since it stays in the project's history even after you remove it.
  • Printing or logging a secret's full value anywhere, even for debugging. Logs get copied, forwarded, and stored longer than anyone expects.
  • Deleting the old version the instant you rotate a secret. Anything still using the old value, such as a slow-restarting server or a cached config, breaks immediately instead of getting time to pick up the new one.

Try it — edit and run

Click the code to edit · press ⌘/Ctrl+↵ to run

Editable code. Tab and Shift+Tab indent. Press Escape, then Tab, to move focus out of the editor.

Expected output — hit Run to try it
Stored secret 'db-password' (v1), allowed roles: admin, backend
Stored secret 'api-key' (v1), allowed roles: admin
GET db-password as 'backend' -> allowed (v1, value p***1)
GET db-password as 'frontend' -> denied (role not permitted)
GET api-key as 'backend' -> denied (role not permitted)
Rotated 'db-password' -> now v2
GET db-password as 'backend' (latest) -> allowed (v2, value p***2)
GET db-password as 'backend' (v1 explicitly) -> allowed but OUTDATED (v1, value p***1) - rotate callers off old versions

Not sure this is the right topic? See the learning paths → or where this leads →