Vault Policies and Access Control
What You'll Learn
You'll learn how to write HCL policies that define granular, path-based permissions in HashiCorp Vault using capabilities like read, write, and delete.
The Core Idea
Vault policies are the gatekeeper of your secrets. Think of them like security clearance levels: you define exactly which paths (secrets locations) different users, applications, or teams can access, and exactly what they can do at those paths.
Policies are written in HashiCorp Configuration Language (HCL), a human-readable format that maps paths to capabilities—the actions allowed on those paths.
Common Capabilities
The main capabilities you'll use:
read– retrieve secret valueswrite– create or update secretsdelete– remove secretslist– see what paths exist (without reading values)deny– explicitly block access (overrides other permissions)
Basic Policy Structure
# Allow reading production database credentials
path "database/creds/prod" {
capabilities = ["read"]
}
# Allow full management of dev secrets
path "secret/data/dev/*" {
capabilities = ["create", "read", "update", "delete", "list"]
}
# Explicitly deny access to sensitive paths
path "secret/data/admin/*" {
capabilities = ["deny"]
}
The asterisk (*) acts as a wildcard for any sub-path.
Path Matching Matters
Policies are deny by default—if no policy grants access to a path, access is blocked. More specific paths override broader ones, and deny always wins.
Key Takeaway: Vault policies use HCL to map specific secret paths to granular capabilities (read, write, delete), enforcing least-privilege access with path-based rules that default to deny unless explicitly permitted.