Chapter 12 / 28
Understanding Dynamic Secrets
HashiCorp Vault For Beginners6 min read
Imagine you’re working in a growing team. You’ve got developers, DevOps folks, and maybe even a few interns. All of them need access to sensitive systems — databases, cloud accounts, message queues, internal APIs…
So you do what most teams do:
- Create a shared DB user.
- Give out long-lived cloud keys.
- Hope everyone remembers to rotate them.
- Panic when someone leaves the company.
Now, enter Vault’s dynamic secrets — your new best friend.
What Are Dynamic Secrets?
Dynamic secrets are ephemeral credentials Vault generates on-demand.
Instead of creating a user manually and storing their password in Vault (a static secret), Vault talks to your system (like a database or cloud provider), creates a brand-new user with a random password, hands it over to the requester, and then destroys it after some time.
These secrets:
- Are unique per request
- Have a short lifespan
- Are automatically revoked
- Leave zero traces once expired
It’s like printing a backstage pass that self-destructs after the show.
What Systems Can Use Dynamic Secrets?
Vault supports dynamic secret generation for:
| Secret Engine | Use Case |
|---|---|
| Databases | Generate DB users for PostgreSQL, MySQL, MSSQL, etc. |
| Cloud Platforms | AWS, Azure, GCP – create short-lived API keys or IAM roles |
| SSH | One-time SSH access for remote machines |
| PKI | Create short-lived TLS certificates for apps |
| TOTP | Time-based OTP generation |
| RabbitMQ / MongoDB / Cassandra | Temporary app credentials |
More integrations are constantly added. If your system can create users or rotate credentials, Vault can probably automate it.
Why Use Dynamic Secrets?
Here’s what makes dynamic secrets a game-changer:
1. Time-Limited Access
No more infinite credentials lying around. You request access, use it, and Vault automatically revokes it after a set TTL (Time-To-Live).
2. Zero Sharing
Everyone gets their own secret. No more shared logins floating around in Slack or email.
3. Audit-Ready
Every issued secret has a traceable path: who requested it, when, and for what.
4. Kill Switch
If something smells fishy, you can revoke the secret instantly — like shutting off a keycard in a hotel.
5. Perfect for Automation
CI pipelines, temporary microservices, even short-lived development environments — Vault can create and destroy credentials on the fly.
Real-World Scenarios
Example 1: Dev Access to Databases
A developer needs read access to the production PostgreSQL database for 20 minutes.
- Vault creates a user like
v-token-readonly-12X9with a random password. - Dev connects using it.
- After 20 minutes, Vault deletes that user from PostgreSQL.
- Nothing to clean up. No password to rotate.
Example 2: CI/CD Deployment to AWS
Your deployment pipeline needs to upload files to S3.
- Instead of hardcoding an IAM key in GitHub Actions, your pipeline logs in to Vault.
- Vault generates temporary AWS keys with scoped permissions.
- The job runs. Vault revokes the key after 15 minutes.
- Your AWS account stays clean and locked down.
Example 3: Secure Onboarding
A new engineer joins the team.
- You give her Vault access with limited policies.
- She requests credentials for staging systems through Vault.
- No need to update .env files, no shared secrets, no accidental leaks.
The Payoff
With dynamic secrets:
- Your secrets stay fresh.
- Your blast radius shrinks.
- Your compliance posture improves.
- Your security team sleeps better.
It’s one of those features that makes you rethink how secrets should work.
Now that your mind is prepped — in the next chapter, we’ll get hands-on. We’ll connect Vault to a real system (like MySQL), configure the secret engine, create a dynamic role, and watch Vault generate credentials on the fly.
You’re going to love it.
Let’s go build it.