HashiCorp Vault
The industry-standard secrets management platform for securing API keys, passwords, certificates, and database credentials. Vault's most powerful feature: dynamic secrets — on-demand, short-lived credentials for databases, AWS, and PKI that are automatically revoked, eliminating long-lived credential leaks.
What is HashiCorp Vault?
Vault is more than a secret store — it is a secret lifecycle management platform. Where environment variables or AWS Secrets Manager store static credentials, Vault generates ephemeral credentials on demand. When your app requests a Postgres credential, Vault creates a real database user with a 1-hour TTL, returns the username and password, and revokes both when the lease expires. The database never has long-lived app credentials.
Vault's policy system (HCL) controls exactly which paths each token can access and with which operations (read, write, list, delete). Every request is logged in the immutable audit log. Integration with Kubernetes via the Agent Injector or Secrets Operator makes it the standard choice for secret management in cloud-native environments.
Quick Start (Docker)
# Development server (in-memory, no persistence) docker run --cap-add=IPC_LOCK -p 8200:8200 hashicorp/vault server -dev # Production (file storage) docker run --cap-add=IPC_LOCK -p 8200:8200 -v vault-config:/vault/config -v vault-data:/vault/data hashicorp/vault server # Access UI at http://localhost:8200 # Dev mode root token: printed in container logs
Policies and Dynamic Secrets
# Vault policy (HCL)
# web-app-policy.hcl
path "secret/data/web-app/*" {
capabilities = ["read", "list"]
}
path "database/creds/web-app-role" {
capabilities = ["read"]
}
path "pki/issue/web-app-cert" {
capabilities = ["create", "update"]
}
# Apply policy
vault policy write web-app web-app-policy.hcl
# Write a secret
vault kv put secret/web-app/database username=appuser password=s3cr3t
# Read a secret
vault kv get secret/web-app/database
# Enable dynamic database secrets
vault secrets enable database
vault write database/config/postgres plugin_name=postgresql-database-plugin connection_url="postgresql://{{username}}:{{password}}@postgres:5432/app" allowed_roles="web-app-role" username=vaultadmin password=vaultpass Node.js Integration
// Node.js — fetch secrets from Vault
import vault from 'node-vault';
const client = vault({
apiVersion: 'v1',
endpoint: process.env.VAULT_ADDR,
token: process.env.VAULT_TOKEN,
});
// KV v2 — read secret
const { data } = await client.read('secret/data/web-app/database');
const { username, password } = data.data;
// AppRole auth (recommended for apps)
const { auth } = await client.approleLogin({
role_id: process.env.VAULT_ROLE_ID,
secret_id: process.env.VAULT_SECRET_ID,
});
client.token = auth.client_token;
// Dynamic database credentials (short-lived, rotated)
const dbCreds = await client.read('database/creds/web-app-role');
// dbCreds.data.username and dbCreds.data.password are ephemeral Kubernetes Agent Injector
# Vault Agent Injector — auto-inject secrets into Pods
# Install via Helm
helm repo add hashicorp https://helm.releases.hashicorp.com
helm install vault hashicorp/vault --set "injector.enabled=true" --namespace vault --create-namespace
# Annotate deployment to inject secrets
apiVersion: apps/v1
kind: Deployment
metadata:
name: web-app
spec:
template:
metadata:
annotations:
vault.hashicorp.com/agent-inject: "true"
vault.hashicorp.com/role: "web-app"
vault.hashicorp.com/agent-inject-secret-db: "secret/data/web-app/database"
vault.hashicorp.com/agent-inject-template-db: |
{{- with secret "secret/data/web-app/database" -}}
export DB_USER="{{ .Data.data.username }}"
export DB_PASS="{{ .Data.data.password }}"
{{- end }} Related Products
on GumroadDeveloper Productivity Bundle
Stop rebuilding the same setup every project. 51 VSCode snippets, 40 Git aliases, 5 Docker Compose stacks, 5 GitHub Actions workflows, 5 README templates, and a dotfiles kit. Set up a professional dev environment in under an hour.
Buy on Gumroad →AI Prompt Engineering Toolkit
58 structured prompt templates for Claude, ChatGPT, and Gemini — organized by use case. Code Review, Debugging, Documentation, Architecture, and 10 model-specific tips. Stop writing prompts from scratch.
Buy on Gumroad →Developer Cheat Sheet Bundle
10 print-ready cheat sheets for the tools developers use every day: Git, Docker, Linux CLI, SQL, Regex, HTTP Status codes, VS Code shortcuts, Bash scripting, jq/JSON, and Markdown.
Buy on Gumroad →You Might Also Need
JSON Formatter & Validator
Format, beautify, and validate JSON online. Paste your JSON to instantly pretty-print it with 2-space, 4-space, or tab indentation. Minify JSON too. Free, runs in your browser.
Open free tool →
Regex Tester
Free regex tester. Test regular expressions against multiple strings with expected match/no-match assertions — see instant pass/fail results. Built-in presets for email, URL, IPv4, and phone. Pro: unl
Open free tool →
Base64 Encoder & Decoder
Free Base64 Encoder & Decoder. Convert text, images, and any file to Base64 and back. Supports URL-safe Base64, image data URIs, and file download from Base64. Runs 100% in your browser — no data sent
Open free tool →
More Free Tools
Related Articles
curl 深度使用手冊:API 測試從入門到進階
curl 是每位開發者必備的 CLI 工具。本文涵蓋 GET/POST/PUT/DELETE 請求、認證、header 設定、檔案上傳、除錯技巧,以及 REST API 測試的完整實戰範例。
Best AI Code Review Tools 2026: CodeRabbit, Sourcery, DeepCode & Bito Compared
Compare top AI code review tools for 2026: CodeRabbit, Sourcery, DeepCode, and Bito. Features, pricing, GitHub/GitLab integration, and choosing the right tool for your team.
AI Code Review Tools 2026: GitHub Copilot, CodeRabbit, Qodo Merge Ranked
Compare AI code review tools for 2026: GitHub Copilot code review, CodeRabbit, Qodo Merge, Sourcery, and PR-Agent. Pricing, accuracy, and GitHub integration.
AI Coding Tools Comparison 2026: GitHub Copilot vs Cursor vs Windsurf vs Cline
Comprehensive comparison of the best AI coding tools in 2026: GitHub Copilot, Cursor, Windsurf, and Cline. Pricing, features, model support, and real-world benchmarks.
AI Pair Programming in 2026: GitHub Copilot vs Cursor vs Claude Code
Master AI pair programming in 2026. Compare GitHub Copilot, Cursor, and Claude Code for autocomplete, chat, and agentic workflows. Includes setup guides and productivity tips.
Enjoying this tool? Get more like it.
Weekly developer tool guides, productivity playbooks & AI tricks. Free. No spam.
Unlock AI-Powered Dev Tools
- ⚡ AI Code Review, Doc Generator & SQL Builder
- ⚡ All premium templates & early access
- ⚡ Member discounts on Gumroad products
$9/mo after trial · Cancel anytime
Want the full toolkit?
Get DevPlaybook Pro
Every template, guide, boilerplate, and automation script in one bundle. 13 premium products — grab them all at once and save big.
MIT licensed · Instant download · No subscription
See what's included → Browse all deals →