Skip to content

Commit 5cc0160

Browse files
authored
Merge pull request #459 from hashicorp/repo-sync
Repo sync
2 parents 024e611 + 5de06f8 commit 5cc0160

File tree

1 file changed

+13
-49
lines changed

1 file changed

+13
-49
lines changed

content/terraform-docs-common/docs/cloud-docs/workspaces/policy-enforcement/prewritten-sentinel.mdx

Lines changed: 13 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ page_title: Run pre-written Sentinel policies
33
description: Learn how to download and install pre-written Sentinel policies created and maintained by HashiCorp.
44
---
55

6-
# Run pre-written Sentinel policies
6+
# Run pre-written Sentinel policies
77

88
This topic describes how to run Sentinel policies created and maintained by HashiCorp. For instructions about how to create your own custom Sentinel policies, refer to [Define custom Sentinel policies](/terraform/cloud-docs/policy-enforcement/define-policies/custom-sentinel).
99

@@ -13,10 +13,10 @@ Pre-written Sentinel policy libraries streamline your compliance processes and e
1313

1414
Complete the following steps to implement pre-written Sentinel policies in your workspaces:
1515

16-
1. Obtain the policies you want to implement. Download policies directly into your repository or create a fork of the HashiCorp repositories.
16+
1. Obtain the policies you want to implement. Download policies directly into your repository or create a fork of the HashiCorp repositories.
1717
1. Connect policies to your workspace. After you download policies or fork policy repositories, you must connect them to your HCP Terraform or Terraform Enterprise workspaces.
1818

19-
Refer to the [Sentinel documentation](/sentinel/docs) for information about the Sentinel language.
19+
Refer to the [Sentinel documentation](/sentinel/docs) for information about the Sentinel language.
2020

2121
## Requirements
2222

@@ -40,23 +40,22 @@ You must have a GitHub account connected to HCP Terraform or Terraform Enterpris
4040

4141
Refer to the [pre-written policy library reference](/terraform/cloud-docs/policy-enforcement/prewritten-library) for a complete list of available policy sets. Use one of the following methods to get pre-written policies:
4242

43-
- **Download policies from the registry**: Use this method if you want to assemble custom policy sets without customizing policies.
44-
- **Fork the HashiCorp policy GitHub repository**: Use this method if you intend to customize the policies.
45-
- **Add the Terraform module to your configuration**: Use this method to implement specific versions of the policies as-is. This method also connects the policies to workspaces in the Terraform configuration file instead of connecting them as a separate step.
43+
- **Download policies from the registry**: Use this method if you want to assemble custom policy sets without customizing policies.
44+
- **Fork the HashiCorp policy GitHub repository**: Use this method if you intend to customize the policies.
4645

4746
<Tabs>
4847

4948
<Tab heading="Download from the registry">
5049

51-
Complete the following steps to download policies from the registry and apply them directly to your workspaces.
50+
Complete the following steps to download policies from the registry and apply them directly to your workspaces.
5251

5352
1. Browse the policy libraries available in the [Terraform registry](https://registry.terraform.io/search/policies?q=Pre-written).
5453
1. Click on a policy library and click **Choose policies**.
5554
1. Select the policies you want to implement. The registry generates code in the **USAGE INSTRUCTIONS** box.
56-
1. Click **Copy Code Snippet** to copy the code to your clipboard.
55+
1. Click **Copy Code Snippet** to copy the code to your clipboard.
5756
1. Create a GitHub repository to store the policies and the policy set configuration file.
58-
1. Create a file called `sentinel.hcl` in the repository.
59-
1. Paste the code from your clipboard into `sentinel.hcl` and commit your changes.
57+
1. Create a file called `sentinel.hcl` in the repository.
58+
1. Paste the code from your clipboard into `sentinel.hcl` and commit your changes.
6059
1. Complete the instructions for [connecting the policies to your workspace](#connect-policies-to-your-workspace).
6160

6261
</Tab>
@@ -76,61 +75,26 @@ After forking the repository, complete the instructions for [connecting the poli
7675

7776
</Tab>
7877

79-
This method enables you to connect the policies to workspaces in the Terraform configuration file. As a result, you can skip the instructions described in [Connect policies to your workspaces](#connect-policies-to-your-workspaces).
80-
81-
By default, the module supports policies stored in the following repositories:
82-
83-
- [`policy-library-CIS-Policy-Set-for-AWS-Terraform`](https://github.com/hashicorp/policy-library-CIS-Policy-Set-for-AWS-Terraform)
84-
- [`policy-library-FSBP-Policy-Set-for-AWS-Terraform`](https://github.com/hashicorp/policy-library-FSBP-Policy-Set-for-AWS-Terraform/)
85-
86-
Refer to the instructions in the [terraform-AWS-Prewritten-Policy-Set](https://github.com/hashicorp/terraform-AWS-Prewritten-Policy-Set/tree/main) GitHub repository for additional information about using the module, including how to modify or extend the default repositories.
87-
88-
1. Go to the [module in the Terraform registry](https://registry.terraform.io/modules/hashicorp/Prewritten-Policy-Set/AWS/latest) and copy the code generated in the **Provision Instructions** tile.
89-
1. Set the `TFE_TOKEN` environment variable to your HCP Terraform or Terraform Enterprise API token. You can use your token or an organization token.
90-
1. Add the `module` block to your Terraform configuration and define the following arguments:
91-
- `source`: Specify the path to the module you downloaded.
92-
- `tfe_organization`: Specify the name of your organization on Terraform Enterprise or HCP Terraform.
93-
- `policy_set_workspace_names`: Specify a list of workspace names that you want to apply the policies to.
94-
- `name`: Specifies a name for your policy set.
95-
96-
The following example configuration applies invokes the module for `target_workspace_1`:
97-
98-
```hcl
99-
module "policy_set" {
100-
source = "./prewritten-policy"
101-
name = "<your-policy-set>"
102-
tfe_organization = "<your-organization>"
103-
policy_set_workspace_names = ["target_workspace_1"]
104-
name = "<name-for-your-policy-set>"
105-
}
106-
```
107-
108-
1. Run `terraform plan` to view the plan.
109-
1. Run `terraform apply` to apply the changes. After running the command, Terraform will evaluate Sentinel policies for each following run of the workspaces you specified.
110-
111-
</Tab>
11278
</Tabs>
11379

11480
## Connect policies to your workspace
11581

116-
Skip this step if you [added the Terraform module](#add-the-terraform-module-to-your-configuration) to your configuration. When you use the module, the `policy_set_workspace_names` argument instructs Terraform to connect the policies to the HCP Terraform workspaces specified in the configuration.
117-
11882
1. Sign in to [HCP Terraform](https://app.terraform.io/) or Terraform Enterprise and navigate to the organization with workspaces you want to connect policies to.
11983
1. Choose **Settings** from the sidebar.
12084
1. Click **Policy Sets** and click **Connect a new policy set**.
12185
1. Click the **Version control provider (VCS)** tile.
12286
1. Enable the **Sentinel** option as the policy framework.
12387
1. Specify a name and description for the set.
12488
1. Configure any additional options for the policy set and click **Next**.
125-
1. Choose the GitHub connection type, then choose the repository you created in [Set up a repository for the policies](#set-up-a-repository-for-the-policies).
89+
1. Choose the GitHub connection type, then choose the repository you created in [Set up a repository for the policies](#set-up-a-repository-for-the-policies).
12690
1. If the `sentinel.hcl` policy set file is stored in a subfolder, specify the path to the file in the **Policies path** field. The default is the root directory.
12791
1. If you want to apply updated policy sets to the workspace from a specific branch, specify the name in the **VCS branch** field. The default is the default branch configured for the repository.
128-
1. Click **Next** and specify any additional parameters you want to pass to the Sentinel runtime and click **Connect policy set** to finish applying the policies to the workspace.
92+
1. Click **Next** and specify any additional parameters you want to pass to the Sentinel runtime and click **Connect policy set** to finish applying the policies to the workspace.
12993

130-
Run a plan in the workspace to trigger the connected policies. Refer to [Start a Terraform run](/terraform/cloud-docs/workspaces/run/remote-operations#starting-runs) for additional information.
94+
Run a plan in the workspace to trigger the connected policies. Refer to [Start a Terraform run](/terraform/cloud-docs/run/remote-operations#starting-runs) for additional information.
13195

13296
## Next steps
13397

13498
- Group your policies into sets and apply them to your workspaces. Refer to [Create policy sets](/terraform/cloud-docs/policy-enforcement/manage-policy-sets#create-policy-sets) for additional information.
13599
- View results and address Terraform runs that do not comply with your policies. Refer to [View results](/terraform/cloud-docs/policy-enforcement/view-results) for additional information.
136-
- You can also view Sentinel policy results in JSON format. Refer to [View Sentinel JSON results](/terraform/cloud-docs/policy-enforcement/view-results/json) for additional information.
100+
- You can also view Sentinel policy results in JSON format. Refer to [View Sentinel JSON results](/terraform/cloud-docs/policy-enforcement/view-results/json) for additional information.

0 commit comments

Comments
 (0)