Vault
Manage access to secrets in HCP Vault Dedicated using policies
Policies are a declarative way to grant or forbid access to certain paths and operations in Vault. In this tutorial, you will create a policy and then edit it to support new requirements.
Note
This step assumes that you created and connected to the HCP Vault Dedicated cluster in the Create a Vault Cluster on HashiCorp Cloud Platform (HCP) step.
Create a policy
You write ACL policies using the HashiCorp Configuration Language (HCL). Here is an example policy:
# Grant 'create', 'read' and 'update' permission to paths prefixed by 'secret/data/test/'
path "secret/data/test/*" {
capabilities = [ "create", "read", "update" ]
}
# Manage namespaces
path "sys/namespaces/*" {
capabilities = [ "create", "read", "update", "delete", "list" ]
}
The policy format uses a prefix matching system on the API path to determine access control. The most specific defined policy takes precedence, either an exact match or the longest-prefix glob match. Since everything in Vault uses the Vault API, this gives strict control over every aspect of Vault, including enabling secrets engines, enabling auth methods, authenticating, as well as secret access.
Important
You create policies in a namespace. When you create a policy
in the admin/
namespace, the policy is only available in the admin/
namespace. This keeps each namespace isolated and secure.
Warning
There are two out-of-the-box policies in the admin/
namespace:
default
and hcp-root
. Do NOT edit the hcp-root
policy. The admin token
generated by the HCP
portal has the
hcp-root
policy attached, granting permissions necessary for initial setup.
Modifying this policy can prevent you from performing admin tasks.
In the Vault UI, set the current namespace to
admin/
.Click Policies.
Select Create ACL policy.
Enter
tester
in the Name field.Enter the following policy in the Policy textbox.
# Grant 'create', 'read' and 'update' permission to paths prefixed by 'secret/data/test/' path "secret/data/test/*" { capabilities = [ "create", "read", "update" ] } # Manage namespaces path "sys/namespaces/*" { capabilities = [ "create", "read", "update", "delete", "list" ] }
Tip
You can review an example policy by clicking the example template link under the Policy textbox.
Click Create policy at the bottom of the page.
Vault displays the policy name and contents.
Policies to access another namespace
The policy path is relative to the namespace in which you create the policy. If
you want to access the database/
path in the admin/education/training
namespace from the admin
namespace, the policy path must be
education/training/database/*
.

The policy you deploy in the admin
namespace must look similar to the
following:
# Grant CRUD operations against the path prefixed with 'database/' in the 'training' namespace
path "education/training/database/*" {
capabilities = [ "create", "read", "update", "delete" ]
}
The policy you deploy in the admin/education
namespace must look
similar to the following:
# Grant CRUD operations against the path prefixed with 'database/' in the 'training' namespace
path "training/database/*" {
capabilities = [ "create", "read", "update", "delete" ]
}
To learn more, read the Secure Multi-Tenancy with Namespaces tutorial.
Summary
You created a policy in Vault. Vault attaches policies to tokens that Vault generates through its various authentication methods.
You created a policy from a file. Policy authoring requires an understanding of paths which map to the Vault API endpoints, and the available actions for each path. Learn more about policies.
In addition to ACL policies, HCP Vault Dedicated Plus tier also supports Sentinel policies to enable fine-grained, logic-based policy decisions.