Course contentsShow
← Cloud and Infrastructure
Lesson 2264 of 2,98948. Secrets ManagementFree lesson

Vault Policies and Access Control

Writing HCL policies to define path-based permissions with capabilities like read, write, delete.

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 values
  • write – create or update secrets
  • delete – remove secrets
  • list – 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.