Update pre-written policies in a policy set
This topic shows how to update a policy set containing pre-written policies. If you want to create a policy set using pre-written policies, refer to Create a policy set using pre-written policies.
When you add a pre-written policy to a policy set, HCP Terraform creates a copy of that policy for the policy set.
When HashiCorp publishes a new version of the policy, your policy sets do not update automatically. Policy sets continue to use their current version until you update them.
Updating a policy, either individually or in bulk, affects only the policy set where you perform the update. Other policy sets that use the same policy are not changed, so you must update each policy set separately. This applies to policy sets scoped to workspaces, projects, and Stacks.
Updating a policy does not change its enforcement level.
Update alert
When pre-written policies included in your policy sets receive an update, HCP Terraform notifies you:
- Via email, if configured.
- Via a global alert.
- On the Policy sets page.
The alert signals that one or more of the policies you use in your policy sets have an available update and provides you with a link or a button to navigate to the Policy sets page where the policy sets that have available updates are filtered.
You can retrieve the same information from the Policy sets page by using the filter in the top row of the policy sets table.
- Click the Filters dropdown.
- Under Policy version, select Needs update.
This shows a list of all policy sets that contain policies that need an update.
The update warning remains in the interface as a reminder until you update the policies, even if you close the alert banner.
Update a policy set
You can update policies in a policy set either one by one or you can do a bulk upgrade.
Update a single policy
Use this procedure if the policy set contains only one updatable policy, or if you want to update your policies one at a time.
- In the policy set details page navigate to the Connected pre-written policies section.
- In the table, click the
...button for the policy you want to update. - In the dropdown click Review and update. A page opens, showing you the diff between the two versions of the policy.
- Review the diff and then click the Update to latest button.
- A message stating Policy updated with details over the policy name will appear on the bottom right part of the page.
Bulk update policies
When the policy set contains multiple policies that can be updated you can update them all in a single operation.
- In the policy set details page navigate to the Connected pre-written policies section.
- Click the Filters dropdown in the policies table.
- Under Policy version, select Needs update.
- From the filtered results table, select all policies.
- In the filter bar click the Actions dropdown.
- Click Review and update policies. A page opens, showing all the policies that need review.
- For each policy you want to review:
- In the table, click the
...button for the policy you want to update. - Click Review policy code. A page opens, showing you the diff between the two versions of the policy.
- Review the diff and then click the Back to review and update policies button.
- In the table, click the
- Once you reviewed all the policies, click the Update all to latest button.
- A message stating All policies updated with details over the number of updated policies will appear on the bottom right part of the page.