Skip to content

Commit

Permalink
Add example and docs template for change request policies
Browse files Browse the repository at this point in the history
  • Loading branch information
emily-curry committed Dec 19, 2024
1 parent b73be50 commit 42fc41b
Show file tree
Hide file tree
Showing 2 changed files with 93 additions and 0 deletions.
69 changes: 69 additions & 0 deletions examples/resources/change_request_policy.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
data "doppler_user" "nic" {
email = "[email protected]"
}

data "doppler_user" "emily" {
email = "[email protected]"
}

resource "doppler_project" "test_proj" {
name = "my-test-project"
description = "This is a test project"
}

resource "doppler_environment" "prd" {
project = doppler_project.test_proj.name
slug = "prd"
name = "prd"
}

resource "doppler_environment" "ci" {
project = doppler_project.test_proj.name
slug = "ci"
name = "CI-CD"
}

resource "doppler_config" "ci_github" {
project = doppler_project.test_proj.name
environment = doppler_environment.ci.slug
name = "ci_github"
}

resource "doppler_group" "prod_reviewers" {
name = "Prod Reviewers"
}

resource "doppler_group_member" "prod_reviewers" {
for_each = toset([data.doppler_user.nic.slug])
group_slug = doppler_group.prod_reviewers.slug
user_slug = each.value
}

resource "doppler_change_request_policy" "prd_review" {
name = "Prod Review"
description = <<EOT
A change request policy which requires 2 total approvals, and 1 approval from emily or any member of the prod_reviewers group.
Reviews from the author of the change request are not counted.
This policy is enforced in all configs of the prd environment of test_proj, as well as the ci_github branch config.
EOT
rules {
disallow_self_review = true

required_reviewers {
count = 2
}

required_reviewers {
count = 1
group_slugs = [doppler_group.prod_reviewers.slug]
user_slugs = [data.doppler_user.emily.slug]
}
}
targets {
project {
project_name = doppler_project.test_proj.name
environment_slugs = [doppler_environment.prd.slug]
config_names = [doppler_config.ci_github.name]
}
}
}
24 changes: 24 additions & 0 deletions templates/resources/change_request_policy.md.tmpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
---
page_title: "doppler_change_request_policy Resource - terraform-provider-doppler"
subcategory: ""
description: |-
Manage a Doppler change request policy.
---

# doppler_change_request_policy (Resource)

Manage a Doppler change request policy.

## Example Usage

{{tffile "examples/resources/change_request_policy.tf"}}

{{ .SchemaMarkdown | trimspace }}

## Import

Import is supported using the following syntax:

```shell
terraform import doppler_change_request_policy.<name> <change-request-policy-id>
```

0 comments on commit 42fc41b

Please sign in to comment.