Skip to content

Commit 8bbd35c

Browse files
authored
Clarifying policy checking docs (#1621)
* Clarifying policy checking docs * adding info about attributes * add more clarifying text
1 parent 6b50e84 commit 8bbd35c

File tree

2 files changed

+19
-15
lines changed

2 files changed

+19
-15
lines changed

Diff for: runatlantis.io/docs/policy-checking.md

+14-10
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
# Conftest Policy Checking
22

3-
Atlantis supports running server-side [conftest](https://www.conftest.dev/) policies against the plan output. Common usecases
3+
Atlantis supports running server-side [conftest](https://www.conftest.dev/) policies against the plan output. Common usecases
44
for using this step include:
5-
* Denying usage of a list of modules
6-
* Asserting attributes of a resource at creation time
7-
* Catching unintentional resource deletions
8-
* Preventing security risks (ie. exposing secure ports to the public)
95

6+
- Denying usage of a list of modules
7+
- Asserting attributes of a resource at creation time
8+
- Catching unintentional resource deletions
9+
- Preventing security risks (ie. exposing secure ports to the public)
1010

1111
## How it works?
1212

@@ -32,7 +32,7 @@ This section will provide a guide on how to get set up with a simple policy that
3232

3333
Enable the workflow using the following server configuration flag `--enable-policy-checks`
3434

35-
### Step 3: Define the policy configuration
35+
### Step 2: Define the policy configuration
3636

3737
Policy Configuration is defined in the [server-side repo configuration](https://www.runatlantis.io/docs/server-side-repo-config.html#reference).
3838

@@ -45,13 +45,17 @@ policies:
4545
- nishkrishnan
4646
policy_sets:
4747
- name: null_resource_warning
48-
path: <CODE_DIRECTORY>/policies/null_resource_warning
48+
path: <CODE_DIRECTORY>/policies/null_resource_warning/
4949
source: local
5050
```
5151

52-
### Step 4: Write the policy
52+
`name` - A name of your policy set.
53+
`path` - Path to a policies directory.
54+
`source` - Tells atlantis where to fetch the policies from. Currently you can only host policies locally by using `local`.
5355

54-
Conftest policies are based on [Open Policy Agent (OPA)](https://www.openpolicyagent.org/) and written in [rego](https://www.openpolicyagent.org/docs/latest/policy-language/#what-is-rego). The following shows a simple policy written to fail for plans containing newly created `null_resource`s.
56+
### Step 3: Write the policy
57+
58+
Conftest policies are based on [Open Policy Agent (OPA)](https://www.openpolicyagent.org/) and written in [rego](https://www.openpolicyagent.org/docs/latest/policy-language/#what-is-rego). Following our example, simply create a `rego` file in `null_resource_warning` folder with following code, the code below a simple policy that will fail for plans containing newly created `null_resource`s.
5559

5660
```
5761
package main
@@ -88,7 +92,7 @@ deny[msg] {
8892
```
8993

9094
::: tip Notes
91-
By default conftest is configured to only run the `main` package. If you want to change this behavior [`extra_args`](https://www.runatlantis.io/docs/custom-workflows.html#adding-extra-arguments-to-terraform-commands) can be used to pass in flags to conftest such as `--namespace` or `--all-namespaces`
95+
By default conftest is configured to only run the `main` package. If you want to change this behavior [`extra_args`](https://www.runatlantis.io/docs/custom-workflows.html#adding-extra-arguments-to-terraform-commands) can be used to pass in flags to conftest such as `--namespace` or `--all-namespaces`
9296
:::
9397

9498
That's it! Now your Atlantis instance is configured to run policies on your Terraform plans 🎉

Diff for: runatlantis.io/docs/server-side-repo-config.md

+5-5
Original file line numberDiff line numberDiff line change
@@ -426,9 +426,9 @@ If you set a workflow with the key `default`, it will override this.
426426
| users | []string | none | yes | list of github users that can approve failing policies |
427427

428428
### PolicySet
429-
| Key | Type | Default | Required | Description |
430-
|------------------------|-----------------|---------|-----------|------------------------------------------|
431-
| name | string | none | yes | unique name for the policy set |
432-
| path | string | none | yes | path to the rego policies |
433-
| source | string | none | yes | only `local` is supported at this time |
434429

430+
| Key | Type | Default | Required | Description |
431+
| ------ | ------ | ------- | -------- | -------------------------------------- |
432+
| name | string | none | yes | unique name for the policy set |
433+
| path | string | none | yes | path to the rego policies directory |
434+
| source | string | none | yes | only `local` is supported at this time |

0 commit comments

Comments
 (0)