Dynamic Secrets are short-lived credentials that are issued on demand and automatically revoked when their TTL expires. The biggest win is that they cut both leak risk and operational overhead at the same time.
This article focuses on the concepts and operational patterns most often tested at the Vault Associate / Operations level, with CLI/API walkthroughs, comparison tables, and diagrams that make the full picture click.
Vault's Dynamic Secrets generate unique credentials in the backend on every request, and Vault automatically disables or deletes them once the TTL is reached. This eliminates the long-lived shared passwords that linger because nobody remembers to clean them up, minimizing the blast radius if a credential ever leaks.
The key point is that issuance and revocation are both managed under Vault's lease system. Each credential comes with a lease_id and a lease_duration, and clients can renew or explicitly revoke as needed. This also pairs well with audit logging — you can trace who used which privileges and when.
| Aspect | Dynamic Secrets | Long-lived static secrets | Manually rotated static |
|---|---|---|---|
| Issuance | On-demand per request | Pre-distributed and shared | Periodic manual or scripted rotation |
| Lifetime | Short-lived (TTL-managed), auto-revoked | Indefinite / long-lived | Medium (depends on rotation cycle) |
| Leak impact | Limited (invalidated at expiry) | Broad (persists until revoked) | Depends on rotation timing |
| Auditability | High (every issuance is traceable) | Low (sharing obscures who used what) | Medium (rotation logs only) |
| Operational cost | Low after initial setup | High management load, distribution overhead | Requires rotation jobs and coordination |
On-demand issuance and automatic revocation flow
Minimum configuration example (Database Secrets Engine / Postgres)
vault secrets enable database
vault write database/config/my-postgres \
plugin_name=postgresql-database-plugin \
allowed_roles=readonly \
connection_url="postgresql://{{username}}:{{password}}@db.example.com:5432/postgres?sslmode=verify-full" \
username="vault_admin" \
password="s3cr3t"
vault write database/roles/readonly \
db_name=my-postgres \
creation_statements="CREATE ROLE \"{{name}}\" WITH LOGIN PASSWORD '{{password}}' VALID UNTIL '{{expiration}}'; GRANT SELECT ON ALL TABLES IN SCHEMA public TO \"{{name}}\";" \
default_ttl=1h \
max_ttl=24h
# 短命クレデンシャルの取得
vault read database/creds/readonly
# 出力例: username, password, lease_id, lease_duration, renewable などEvery Dynamic Secret comes with a lease_id and a lease_duration. The lease_duration is the effective TTL at issuance, and you can call lease renew when you need more time. Renewals, however, cannot exceed the role's max_ttl or the system-wide max TTL.
Renewal can fail in three situations: leases with renewable=false, extensions that would breach a ceiling, or backend-specific constraints. When the lease expires, Vault disables or deletes the credential on the target system. Token TTLs and secret TTLs are separate — whichever expires first will block further fetches or renewals.
| Operation | Target | Effect | Caveats |
|---|---|---|---|
| lease renew | A specific lease_id | Extends TTL (within allowed bounds) | Fails when renewable=false or limits are exceeded |
| lease revoke | A specific lease_id | Immediate revocation | Connected apps must re-fetch credentials |
| lease revoke -prefix | All leases under a path | Bulk revocation | Wide blast radius — plan the rollout carefully |
TTL, renewal, and revocation timeline
Inspecting, renewing, and revoking leases
# JSON 出力で lease を確認
vault read -format=json database/creds/readonly | jq '.lease_id, .lease_duration, .renewable'
# 更新(延長)
vault lease renew <LEASE_ID>
# 即時取り消し
vault lease revoke <LEASE_ID>
# パス配下を一括取り消し
vault lease revoke -prefix database/creds/readonlyCloud engines issue short-lived temporary credentials, eliminating the distribution and recovery problems that come with long-lived keys. On AWS, STS-based temporary credentials are the recommended path, with IAM user generation reserved for edge cases. Azure and GCP follow the same pattern, centering on short-lived tokens and ephemeral keys.
From an exam perspective, the points most likely to be tested are: choosing the right credential_type, keeping TTL/Max TTL consistent, scoping role permissions, and understanding what revocation actually does (STS expiry, key deletion, and so on).
| Engine / mode | Type | Typical TTL | Revocation mechanism |
|---|---|---|---|
| AWS STS | Temporary credentials | 15 min – 1 hour | Auto-invalid on expiry |
| AWS IAM User | Long-lived user | Fixed (until deletion) | Revoke deletes the user/key |
| Azure (SP) | Temp secret / assignment | Minutes to hours | Secret revocation / unassignment |
| GCP (roleset) | Temp key / token | Minutes to hours | Key revocation / deletion |
Issuing temporary cloud credentials through Vault
Example: using STS with the AWS engine
vault secrets enable aws
vault write aws/config/root \
access_key=AKIA... \
secret_key=... \
region=ap-northeast-1
vault write aws/roles/readonly-sts \
credential_type=sts \
role_arn=arn:aws:iam::123456789012:role/ReadOnlyRole \
default_sts_ttl=900 \
max_sts_ttl=3600
vault read aws/sts/readonly-sts # AccessKeyId/SecretAccessKey/SessionToken と TTL を取得You can either embed the Vault client directly in your application or deploy Vault Agent as a sidecar/daemon that writes credentials to a file. Because Dynamic Secrets are short-lived, the design around file updates plus signal-based reloads — or reconnection — is critical.
From a zero-trust angle, Response Wrapping reduces exposure of credentials and tokens along the handoff path. The exam often probes the one-time, short-lived nature of wrapping tokens and where the responsibility for unwrap lies.
| Integration approach | Pros | Caveats |
|---|---|---|
| Direct library integration | Fine-grained control | Implementation cost; needs language support |
| Vault Agent (sidecar) | No code required; standardized | Requires file distribution and reload control |
| Init + Wrapping | Safer initial distribution | Need unwrap procedure and expiry management |
Credential delivery via an Agent sidecar
Minimum Vault Agent config example (AppRole + Template)
auto_auth {
method "approle" {
mount_path = "auth/approle"
config = {
role_id_file_path = "/etc/vault/role_id"
secret_id_file_path = "/etc/vault/secret_id"
}
}
sink "file" {
config = { path = "/etc/vault/token" }
}
}
template {
source = "/etc/vault/templates/db.tpl"
destination = "/etc/secrets/db.env"
command = "/usr/local/bin/reload-app"
}
vault {
address = "https://vault.example.com:8200"
}
# db.tpl の例:
# export DB_USER="{{ with secret \"database/creds/readonly\" }}{{ .Data.username }}{{ end }}"
# export DB_PASS="{{ with secret \"database/creds/readonly\" }}{{ .Data.password }}{{ end }}"To enforce least privilege, grant the application token only the read paths it actually needs (e.g. database/creds/role). Administrators can use revoke -prefix to perform planned bulk revocations scoped to a blast radius. Audit logs trace every issuance, renewal, and revocation, making incident response much easier.
Common exam pitfalls include conflating token TTL with secret TTL (they are independent), misunderstanding the relationship between default_ttl and max_ttl, and the behavior of orphan tokens with respect to revoke propagation. Keep each concept cleanly separated in your head.
| Command / setting | Effect | Exam pitfall |
|---|---|---|
| vault lease revoke -prefix path | Bulk-revoke dynamic secrets under the path | Underestimating the blast radius |
| vault audit enable file | Enable audit logging | Cases where permissions or path issues block writes |
| Read control via policy | Removes unnecessary privileges | Confusing read capability between creds and roles/config |
Lease hierarchy and bulk revocation picture
Least-privilege policy and enabling audit
# アプリが readonly 資格情報だけ取得可能にする例
path "database/creds/readonly" {
capabilities = ["read"]
}
# 監査ログをファイルで有効化
vault audit enable file file_path=/var/log/vault_audit.logCommon failures include role name mismatches, renewals that exceed max_ttl, insufficient backend privileges (e.g. no CREATE ROLE on the DB), and insufficient token capabilities (no read). When you see messages like lease TTL too large, permission denied, or no handler for route, suspect TTL ceilings, policy issues, and mount/path mistakes respectively.
In production, the keys to stable operation are: a connection pool refresh strategy (reconnect on rotation), a retry window for network partitions, and visibility into audit logs and metrics (issuance failure rate, renewal failure rate).
| Symptom | Main cause | Fix |
|---|---|---|
| lease TTL too large | Requested TTL exceeds max_ttl or system ceiling | Review the role's max_ttl and the sys-level ceiling |
| permission denied | Token capabilities are insufficient | Update the policy to grant read, etc. |
| no handler for route | Wrong path/mount or engine not enabled | Re-check secrets enable and the path |
Quick diagnostic flow
Diagnostic command / API snippets
# マウント一覧
vault list sys/mounts
# ロール定義の確認
vault read database/roles/readonly
# API 例: 認証後に creds を取得
curl -s \
-H "X-Vault-Token: $VAULT_TOKEN" \
https://vault.example.com/v1/database/creds/readonly | jqAssociate / Ops
問題 1
A team wants to use Vault's Database Secrets Engine to make application DB access short-lived. The requirements are: 1) credentials should expire automatically, 2) operational overhead should be minimal, 3) the credential lifetime should be extended only when the workload is high within the lease window. Which design is most appropriate?
正解: A
Requirements 1 and 2 are satisfied by the standard Dynamic Secrets behavior. For requirement 3, lease renew lets you extend on top of default_ttl only when needed, with max_ttl giving you headroom as the ceiling. Shared users or extended token TTLs do not actually manage the secret's lifetime.
What happens if a network partition prevents lease renewal?
If renewal fails, Vault automatically revokes the lease once the TTL expires. The recommended pattern is to attempt renewal well before expiration and fall back to acquiring a fresh credential on failure — a two-stage retry plus failover design.
How should a DB connection pool handle rotated credentials?
Short-lived credentials require re-authentication. Implement a gradual pool refresh (new connections use the new credentials, old connections are closed) and add an application reload hook to pick up the rotated values.
What is a reasonable TTL?
The guiding principle is least privilege and shortest lifetime. Keep the TTL as short as possible without disrupting steady-state availability, and set max_ttl as a buffer for burst extensions. Tune the trade-off between audit overhead and re-issuance cost through monitoring.
Practice with certification-focused question sets
無料で問題を解いてみるNicheeLab Editorial Team
NicheeLab editorial team focused on data engineering and cloud certification learning. Content is structured around practical study needs and official exam domains.
Vault Core Concepts: Sealed/Unsealed, Auth, Secrets (2026)
Vault fundamentals — sealed/unsealed state, auth methods, se...
Vault Operations Professional (VOP-003): Complete Guide (2026)
Pass the Vault Operations Professional exam — enterprise pat...
Vault Path-Based Routing: API URL Structure (2026)
How Vault's path-based routing works — mount points, sub-pat...
Vault Tokens: Auth Token Mechanics (2026)
Token fundamentals — service vs. batch tokens, accessor, ren...
Vault Token Types: Service, Batch, Periodic (2026)
Service vs. batch tokens compared — performance, ACL behavio...