Use HashiCorp managed pre-written policies
Policy sets are collections of policies you can apply globally, to specific projects and workspaces, or to workspaces with specific tags in your organization. For each run in the applicable workspaces, HCP Terraform checks the Terraform plan against the policy set. Depending on the enforcement level, failed policies can stop a run in a workspace. If you do not want to enforce a policy set on a specific project, workspace, or tag, you can exclude it from that set.
View existing policy sets
- Sign in to HCP Terraform or Terraform Enterprise and navigate to your organization.
- Click Settings, then Policy Sets in the sidebar.
This page contains all of the policy sets available in the organization.
Create new policy set
Sign in to HCP Terraform or Terraform Enterprise and navigate to your organization.
Choose Settings from the sidebar, then Policy sets.
Choose the Pre-written policies option.
Select one of the following frameworks:
- Terraform policy: Terraform policy is a policy-as-code framework that integrates directly with Terraform providers. It supports policies written in HashiCorp Configuration Language (HCL) syntax, which lets you reference any resource defined in a Terraform provider.
- Sentinel: Sentinel is a language and framework for policy built to be embedded in existing software to enable fine-grained, logic-based policy decisions.Sentinel policies are written using the Sentinel language.
A policy set can only contain policies that use the same framework. You cannot change a policy set's framework type after creation.
From the table, select all policies you want to add to the policy set.
- Click on a policy name to view the policy details.
- Use the filter bar to search for specific policies.
- Select all desired policies.
Click on the Next button.
Use the ... button for each policy or the Actions dropdown to define the enforcement level for the selected policies. Refer to Policy enforcement levels for more information.
Click on the Next button.
Configure the policy set by adding:
- Policy set name: a unique name for the policy set. You can use any combination of letters, numbers,
-, and_. A name is required. - Policy set description: an optional description of the policy set behavior.
- Scope of policies: the scope the HCP Terraform applies the policies to. Refer to Policy set scope for details.
- Policy set name: a unique name for the policy set. You can use any combination of letters, numbers,
Click Create policy set to finish.