Vault: Centralized Secrets with Dynamic Leasing
Vault is a secrets firewall: it centralizes credentials and issues short-lived leases instead of static keys. Use it when apps need DB passwords not hardcoded. The footgun is using Vault without audit logs, leaving secrets unmonitored.
Why it exists
Hardcoded secrets in config files and environment variables create a cascading failure mode. When a database password is baked into twelve microservices, rotating it after a breach means redeploying everything. Vault was built to break this pattern by making secrets dynamic, leased, and centrally auditable so that compromise of one app does not require a global credential reset.
The mental model
Think of Vault as a smart safe deposit box that rents contents instead of selling them. Rather than handing a developer a static password that lives forever in a repo, Vault generates a temporary credential on demand, sets an expiration timer, and revokes it automatically when the lease ends. The shift is from possession to rental: you do not own the secret, you borrow it.
How it works
Vault exposes a unified API secured by multiple authentication methods such as Kubernetes service accounts, AWS IAM roles, or LDAP. After a client proves its identity, Vault checks policies written in HashiCorp Configuration Language to decide which secrets paths it may read or generate. For dynamic secrets, Vault connects to a target system like PostgreSQL or AWS IAM, creates a new credential pair with a time-to-live value, and returns it to the client. A background renewal process can extend the lease, but if the client crashes or forgets to renew, Vault revokes the credential at the backend to shrink the blast radius. The core storage is encrypted at rest using a master key that is split via Shamir's secret sharing, requiring multiple unseal keys to reconstruct after a restart.
When to use it
Reach for Vault when you run containerized workloads that need database credentials, TLS certificates that must rotate automatically, or cloud API keys that should not appear in CI logs. It shines in regulated environments where every secret access must leave an audit trail, and in multi-tenant platforms where different teams need isolated secret namespaces.
When not to use it
Do not use Vault for high-frequency low-latency lookups that happen millions of times per second; the authentication and policy evaluation overhead adds latency that a local secret cache or environment variable handles better. It is also overkill for a single monolith on one server with two config values. If your team lacks the operational bandwidth to manage unseal keys, backup procedures, and high-availability clustering, Vault becomes a single point of failure rather than a safety net.
One canonical example
A Kubernetes application needs to query a PostgreSQL database. Instead of mounting a static password via a config map, the pod authenticates to Vault using its Kubernetes service account token. Vault verifies the token with the cluster, checks that the pod's service account is bound to a policy allowing database creds, and asks its PostgreSQL secrets engine to create a new username and password valid for one hour. The app reads these from Vault's API at startup, connects to the database, and renews the lease every thirty minutes. If the pod is deleted, the lease expires and Vault automatically drops the PostgreSQL user, ensuring no orphaned credentials linger in the database.
Interview question
What happens to a dynamic secret if the Vault client crashes without renewing its lease?
- a.Vault re-encrypts the secret with a split master key until the client recovers
- b.Vault automatically revokes the credential at the backend systemCorrect
- c.The credential remains valid until an operator manually revokes it
- d.The background renewal process silently extends the lease indefinitely
Why? this is the answer
The card states that if a client crashes or forgets to renew, Vault revokes the credential at the backend to shrink the blast radius. Option D is tempting because the card mentions a background renewal process, but that process requires client interaction to extend a lease rather than silently extending it forever.
Just read this? Test yourself on what you have been reading.
- #vault
- #secrets-management
- #security
- #cicd
- #infrastructure
Put your scrolling time to good use
Learn one idea, try a quiz and save useful cards for revision. Tezvyn makes it easy to learn and stay current in your tech field, a few minutes at a time.
The iPhone app is on the way
We are building it. Until it lands, nothing here is held back from you: every interview card, your saved cards, streaks and the job board all work in Safari, plus hundreds of free practice quizzes of thirty questions each. Sign in and it all carries over to the app the day it arrives.
Want it as an icon? Tap Share at the bottom of Safari, then Add to Home Screen. It opens full screen and the cards you have read stay available offline.
We are hiring for this. Every open role lists the topics its interview covers, so you can prepare for the real thing rather than guessing.
See open roles