Key Concepts
Path-Based Rules
Policies grant capabilities on specific paths. Use wildcards to match multiple paths.
Capabilities
Define allowed operations: create, read, update, delete, list, sudo, deny.
Deny by Default
Users have no access unless explicitly granted by a policy.
Multiple Policies
Users can have multiple policies. Permissions are additive (union of all policies).
Required Permissions
| Action | Permission |
|---|---|
| View policies | iam:project:cicd:vault:read |
| Create/Update policies | iam:project:cicd:vault:write |
| Delete policies | iam:project:cicd:vault:delete |
Capabilities Reference
| Capability | Description | Use Case |
|---|---|---|
create | Create new data at a path | Writing new secrets |
read | Read data from a path | Viewing secret values |
update | Modify existing data | Changing secret values |
delete | Remove data from a path | Deleting secrets |
list | List keys at a path | Browsing folders |
sudo | Access root-protected paths | Admin operations |
deny | Explicitly deny access | Override inherited permissions |
How to Create a Policy
Enter Policy Name
Provide a unique, descriptive name:
- Use lowercase with hyphens (e.g.,
app-read-only) - Only alphanumeric, hyphens, and underscores allowed
Write Policy Rules
Define access rules in HCL format. Click Insert Example to start with a template.
Policy Syntax
Policies use HCL (HashiCorp Configuration Language) syntax:Path Patterns
| Pattern | Matches |
|---|---|
secret/data/app | Exact path only |
secret/data/app/* | All direct children |
secret/data/app/+/config | Single-level wildcard |
secret/+/* | Combination patterns |
For KV v2 secrets engine, use
secret/data/* for reading/writing secrets and secret/metadata/* for listing and metadata operations.Common Policy Examples
Read-Only Policy
Application-Specific Policy
Team Lead Policy
Deny Specific Paths
How to Edit a Policy
How to Delete a Policy
Best Practices
Naming Conventions
Principle of Least Privilege
Grant minimum necessary permissions:Use Comments
Document the purpose of each rule:Separate by Environment
Create environment-specific policies:Troubleshooting
Policy not taking effect
Policy not taking effect
- Users may need to log out and back in
- Token may be cached with old permissions
- Verify the policy is attached to the user/group
Permission denied errors
Permission denied errors
- Check the exact path being accessed matches policy
- For KV v2, ensure using
secret/data/prefix - Verify required capability is included
- Check for explicit
denyrules that may override
Cannot list secrets but can read
Cannot list secrets but can read
listcapability must be on themetadatapath- Add:
path "secret/metadata/*" { capabilities = ["list"] }
Syntax error when saving
Syntax error when saving
- Check for missing closing braces
} - Ensure capabilities are in array format
["read", "list"] - Verify no trailing commas in capability arrays
- Use the Insert Example button to compare syntax
Cannot delete policy
Cannot delete policy
- You need delete permission for Vault policies
- Built-in policies (root, default) cannot be deleted
- Check with administrator for policy management permissions
FAQ
What happens when a user has multiple policies?
What happens when a user has multiple policies?
Permissions are additive. If policy A grants read and policy B grants write, the user has both read and write access. However, explicit
deny always wins.Can I test a policy before applying?
Can I test a policy before applying?
Use the Vault CLI
vault token capabilities command to test what operations are allowed for a token on a specific path.What's the difference between secret/data and secret/metadata?
What's the difference between secret/data and secret/metadata?
For KV v2 secrets engine:
secret/data/*- Read/write actual secret valuessecret/metadata/*- List paths, read/write metadata, delete versions
Can policies reference environment variables?
Can policies reference environment variables?
No. Policies are static HCL documents. Use templated policies with Vault Enterprise, or create separate policies per environment.
How do I grant admin access?
How do I grant admin access?
For full administrative access, attach the
root policy. Use sparingly and prefer scoped policies for day-to-day operations.Are policy names case-sensitive?
Are policy names case-sensitive?
Yes.
MyPolicy and mypolicy are different policies. Use consistent lowercase naming.