-
Notifications
You must be signed in to change notification settings - Fork 147
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #694 from hashicorp/mr/TF-1451-docs
Add Documentation : OPA support for policies and policy sets
- Loading branch information
Showing
5 changed files
with
92 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
--- | ||
layout: "tfe" | ||
page_title: "Terraform Enterprise: tfe_policy" | ||
sidebar_current: "docs-resource-tfe-policy" | ||
description: |- | ||
Manages policies. | ||
--- | ||
|
||
# tfe_policy | ||
|
||
Policies are rules enforced on Terraform runs. You can use policies to validate that the Terraform plan complies with security rules and best practices. | ||
Two policy-as-code frameworks are integrated with Terraform Enterprise: Sentinel and Open Policy Agent (OPA). | ||
|
||
Policies are configured on a per-organization level and are organized and | ||
grouped into policy sets, which define the workspaces on which policies are | ||
enforced during runs. | ||
|
||
|
||
## Example Usage | ||
|
||
Basic usage for Sentinel: | ||
|
||
```hcl | ||
resource "tfe_policy" "test" { | ||
name = "my-policy-name" | ||
description = "This policy always passes" | ||
organization = "my-org-name" | ||
kind = "sentinel" | ||
policy = "main = rule { true }" | ||
enforce_mode = "hard-mandatory" | ||
} | ||
``` | ||
|
||
Basic usage for Open Policy Agent(OPA): | ||
|
||
```hcl | ||
resource "tfe_policy" "test" { | ||
name = "my-policy-name" | ||
description = "This policy always passes" | ||
organization = "my-org-name" | ||
kind = "opa" | ||
policy = "package example rule[\"not allowed\"] { false }" | ||
query = "data.example.rule" | ||
enforce_mode = "mandatory" | ||
} | ||
``` | ||
|
||
## Argument Reference | ||
|
||
The following arguments are supported: | ||
|
||
* `name` - (Required) Name of the policy. | ||
* `description` - (Optional) A description of the policy's purpose. | ||
* `organization` - (Required) Name of the organization. | ||
* `kind` - (Optional) The policy-as-code framework associated with the policy. | ||
Defaults to `sentinel` if not provided. Valid values are `sentinel` and `opa`. | ||
* `query` - (Optional) The OPA query to identify a specific policy rule that | ||
needs to run within your Rego code. Required for all OPA policies. | ||
* `policy` - (Required) The actual policy itself. | ||
* `enforce_mode` - (Required) The enforcement level of the policy. Valid | ||
values for Sentinel are `advisory`, `hard-mandatory` and `soft-mandatory`. Defaults | ||
to `soft-mandatory`. Valid values for OPA are `advisory` and `mandatory`. Defaults | ||
to `advisory`. | ||
|
||
## Attributes Reference | ||
|
||
* `id` - The ID of the policy. | ||
|
||
## Import | ||
|
||
Policies can be imported; use `<ORGANIZATION NAME>/<POLICY ID>` as the | ||
import ID. For example: | ||
|
||
```shell | ||
terraform import tfe_policy.test my-org-name/pol-wAs3zYmWAhYK7peR | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters