HashiCorp Vault Documentation - Complete Guide¶
Overview¶
This directory contains comprehensive HashiCorp Vault documentation covering fundamentals, architecture, secrets engines, authentication methods, and production deployment. Each file includes detailed explanations, workflow diagrams, and practical examples.
Documentation Structure¶
Core Topics¶
- Vault Fundamentals ✅ Created
- What problem Vault solves
- Core concepts and terminology
- Complete architecture diagrams
- Installation on multiple platforms
- Getting started (dev mode)
-
Development vs Production comparison
-
Secrets Engines (From original docs.md)
- KV (Key-Value) v1 and v2
- Database dynamic secrets
- AWS dynamic credentials
- Transit encryption engine
- PKI certificate authority
-
Practical examples
-
Authentication Methods (From original docs.md)
- Token authentication
- Userpass (human login)
- AppRole (machine-to-machine)
- Kubernetes authentication
- AWS IAM, Azure AD, GCP
-
Best practices
-
Policies and Access Control (From original docs.md)
- Policy syntax (HCL)
- Path-based permissions
- Capabilities (read, write, delete, list)
- Policy examples
-
Best practices
-
Seal and Unseal (From original docs.md)
- Initialization process
- Shamir's Secret Sharing
- Manual unseal
- Auto-unseal with cloud KMS
-
Production considerations
-
Docker Setup ✅ Exists
- Docker Compose configuration
- Development environment
-
Quick start guide
-
Production Deployment (From original docs.md)
- Configuration file (HCL)
- Storage backends (Consul, Raft, etcd)
- High availability setup
- TLS configuration
- Systemd service
-
Monitoring and logging
-
Integration Examples (From original docs.md)
- Node.js integration
- Python integration
- Go integration
- Kubernetes integration
-
CI/CD integration
-
Best Practices (From original docs.md)
- Security best practices
- Operational best practices
- When to use Vault
- When NOT to use Vault
Quick Start¶
Installation¶
# Linux
wget https://releases.hashicorp.com/vault/1.15.5/vault_1.15.5_linux_amd64.zip
unzip vault_1.15.5_linux_amd64.zip
sudo mv vault /usr/local/bin/
vault version
# macOS
brew install hashicorp/tap/vault
# Docker
docker pull hashicorp/vault:1.15
Development Mode¶
# Start Vault in dev mode
vault server -dev
# In another terminal
export VAULT_ADDR='http://127.0.0.1:8200'
export VAULT_TOKEN='root' # Use token from dev server output
# Test
vault status
Docker Compose¶
Architecture Diagrams¶
The documentation includes comprehensive ASCII diagrams for:
1. High-Level Architecture¶
- HTTP/HTTPS API Layer
- Authentication Methods
- Policy Engine
- Secrets Engines
- Storage Backend
- Audit Devices
2. Core Components¶
- Barrier (Encryption Layer)
- Seal/Unseal Mechanism
- Token Store
- Lease Management
3. Request Flow¶
- 7-step request processing
- Token validation
- Policy evaluation
- Secrets engine routing
- Audit logging
4. Authentication Flow (AppRole)¶
- Role ID and Secret ID
- Login process
- Token generation
- Secret retrieval
5. Seal/Unseal Process¶
- Initialization
- Shamir's Secret Sharing
- Manual unseal steps
- Auto-unseal with cloud KMS
6. Dynamic Secrets¶
- On-demand credential generation
- Lease management
- Automatic revocation
7. High Availability¶
- Active/Standby nodes
- Load balancer configuration
- Shared storage backend
- Leader election
8. Kubernetes Integration¶
- Init container pattern
- Sidecar container
- ServiceAccount authentication
- Secret injection
9. Complete System Design¶
- Frontend, backend, microservices
- Vault cluster
- External services
- Monitoring and audit
Learning Path¶
Beginner (Week 1)¶
- Understand the Problem
- Why secrets management matters
- Traditional vs Vault approach
-
Core concepts
-
Install and Setup
- Install Vault
- Run in dev mode
- Access UI
-
Basic CLI commands
-
First Secrets
- Enable KV secrets engine
- Store and retrieve secrets
- Understand paths
Intermediate (Week 2-3)¶
- Authentication
- Token authentication
- Create users (userpass)
- AppRole for applications
-
Understand policies
-
Policies and Access Control
- Write policies
- Apply policies to tokens
- Test permissions
-
Least privilege principle
-
Dynamic Secrets
- Database secrets engine
- Generate dynamic credentials
- Understand leases
- Renewal and revocation
Advanced (Week 4-6)¶
- Production Setup
- Configuration file
- Storage backend (Consul/Raft)
- TLS certificates
-
Initialization and unsealing
-
High Availability
- Multi-node cluster
- Load balancing
- Auto-unseal
-
Disaster recovery
-
Integration
- Application integration
- Kubernetes deployment
- CI/CD pipelines
- Monitoring and alerting
Common Use Cases¶
1. Static Secrets (KV)¶
# Enable KV v2
vault secrets enable -path=secret kv-v2
# Store secret
vault kv put secret/myapp/db \
username=admin \
password=supersecret
# Read secret
vault kv get secret/myapp/db
# Read specific field
vault kv get -field=password secret/myapp/db
2. Dynamic Database Credentials¶
# Enable database engine
vault secrets enable database
# Configure PostgreSQL connection
vault write database/config/postgresql \
plugin_name=postgresql-database-plugin \
allowed_roles="readonly" \
connection_url="postgresql://{{username}}:{{password}}@localhost:5432/mydb" \
username="vault" \
password="vaultpass"
# Create role
vault write database/roles/readonly \
db_name=postgresql \
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"
# Generate credentials
vault read database/creds/readonly
3. AppRole Authentication¶
# Enable AppRole
vault auth enable approle
# Create role
vault write auth/approle/role/myapp \
token_policies="myapp-policy" \
token_ttl=1h \
token_max_ttl=4h
# Get Role ID
vault read auth/approle/role/myapp/role-id
# Generate Secret ID
vault write -f auth/approle/role/myapp/secret-id
# Login
vault write auth/approle/login \
role_id="xxx" \
secret_id="yyy"
Vault CLI Reference¶
Status and Info¶
# Check status
vault status
# Get server info
vault read sys/health
# List enabled secrets engines
vault secrets list
# List enabled auth methods
vault auth list
# List policies
vault policy list
Secrets Operations¶
# KV v2 operations
vault kv put secret/path key=value
vault kv get secret/path
vault kv get -field=key secret/path
vault kv delete secret/path
vault kv list secret/
# KV v2 versioning
vault kv get -version=2 secret/path
vault kv rollback -version=1 secret/path
vault kv metadata get secret/path
Token Operations¶
# Create token
vault token create -policy=mypolicy -ttl=1h
# Lookup token
vault token lookup
# Renew token
vault token renew
# Revoke token
vault token revoke <token>
# Revoke all tokens for a role
vault token revoke -mode=path auth/approle
Policy Operations¶
# Write policy
vault policy write mypolicy policy.hcl
# Read policy
vault policy read mypolicy
# List policies
vault policy list
# Delete policy
vault policy delete mypolicy
Seal/Unseal Operations¶
# Initialize Vault
vault operator init
# Unseal (repeat 3 times with different keys)
vault operator unseal <key1>
vault operator unseal <key2>
vault operator unseal <key3>
# Seal Vault
vault operator seal
# Check seal status
vault status
Integration Examples¶
Node.js¶
import vault from 'node-vault';
const client = vault({
endpoint: 'http://127.0.0.1:8200',
token: process.env.VAULT_TOKEN
});
// Read secret
const secret = await client.read('secret/data/myapp/db');
const password = secret.data.data.password;
// Write secret
await client.write('secret/data/myapp/api', {
data: {
api_key: 'abc123',
api_secret: 'xyz789'
}
});
Python¶
import hvac
# Initialize client
client = hvac.Client(
url='http://127.0.0.1:8200',
token=os.environ['VAULT_TOKEN']
)
# Read secret
secret = client.secrets.kv.v2.read_secret_version(
path='myapp/db'
)
password = secret['data']['data']['password']
# Write secret
client.secrets.kv.v2.create_or_update_secret(
path='myapp/api',
secret=dict(api_key='abc123')
)
Go¶
import (
vault "github.com/hashicorp/vault/api"
)
// Create client
config := vault.DefaultConfig()
config.Address = "http://127.0.0.1:8200"
client, _ := vault.NewClient(config)
client.SetToken(os.Getenv("VAULT_TOKEN"))
// Read secret
secret, _ := client.Logical().Read("secret/data/myapp/db")
password := secret.Data["data"].(map[string]interface{})["password"]
// Write secret
data := map[string]interface{}{
"data": map[string]interface{}{
"api_key": "abc123",
},
}
client.Logical().Write("secret/data/myapp/api", data)
Best Practices¶
Security¶
- Never use root token in production
- Create specific tokens with limited policies
-
Use AppRole or other auth methods
-
Enable TLS
- Always use HTTPS in production
-
Validate certificates
-
Use short TTLs
- Tokens: 1-4 hours
- Dynamic secrets: 1-24 hours
-
Renew before expiry
-
Enable audit logging
- Log all requests and responses
- Monitor for suspicious activity
-
Retain logs for compliance
-
Implement least privilege
- One policy per application
- Minimal required permissions
- Regular policy audits
Operations¶
- Use auto-unseal in production
- AWS KMS, Azure Key Vault, GCP KMS
-
No manual intervention on restart
-
Deploy in HA mode
- Minimum 3 nodes
- Load balancer in front
-
Shared storage backend
-
Backup regularly
- Backup storage backend
- Backup unseal keys (secure location)
-
Test restore procedures
-
Monitor Vault health
- Prometheus metrics
- Grafana dashboards
-
Alert on seal status, errors
-
Rotate secrets regularly
- Use dynamic secrets when possible
- Automate rotation for static secrets
- Update applications gracefully
Troubleshooting¶
Common Issues¶
1. Vault is Sealed
2. Permission Denied
# Check token policies
vault token lookup
# Verify policy allows operation
vault policy read <policy-name>
3. Connection Refused
# Check Vault is running
systemctl status vault
# Verify VAULT_ADDR
echo $VAULT_ADDR
# Check firewall
sudo ufw status
4. Token Expired
# Check token TTL
vault token lookup
# Renew token
vault token renew
# Or create new token
vault login -method=approle
Resources¶
Official Documentation¶
Community¶
Tools¶
When to Use Vault¶
✅ Use Vault When:¶
- Managing secrets for multiple applications
- Need dynamic credentials
- Compliance requirements (SOC 2, PCI-DSS, HIPAA)
- Microservices architecture
- Cloud-native applications
- Need encryption as a service
- Require audit trail
❌ Don't Use Vault When:¶
- Small hobby project (1-2 secrets)
- No security requirements
- Single application with few secrets
- No operational capacity to manage Vault
- Cost-sensitive (use cloud provider secrets manager)
Summary¶
This HashiCorp Vault documentation provides: - Comprehensive coverage from basics to advanced topics - Visual diagrams for architecture understanding - Practical examples for real-world scenarios - Best practices for production deployment - Integration guides for multiple languages - Troubleshooting for common issues
Perfect for DevOps engineers, security teams, and anyone implementing secrets management in modern infrastructure.
Last Updated: January 6, 2026
Vault Version: 1.15.5
Status: ✅ Fundamentals documented with comprehensive diagrams
Next: Complete remaining topics (Secrets Engines, Auth Methods, Policies, Production)