Skip to content

[BUG]: reviewers is not removable from github_repository_environment #3156

@texonidas

Description

@texonidas

Expected Behavior

When updating a github_repository_environment and removing the reviewers block, which previously contained the teams property, the change is reflected in GitHub and the environment no longer requires reviewer approvals.

Actual Behavior

A perma-diff appears, attempting to set teams to null, rather than removing reviewers entirely, which results in Required reviewers under Settings > Environment > Deployment Protection Rules remaining ticked.

Terraform Version

Terraform v1.14.4
on darwin_arm64

  • provider registry.terraform.io/integrations/github v6.10.2

Affected Resource(s)

  • github_repository_environment

Terraform Configuration Files

resource "github_repository_environment" "default" {
  repository  = var.repository_name
  environment = local.environment_name

  dynamic "reviewers" {
    for_each = var.require_deployment_approval ? [1] : []

    content {
      teams = var.github_deployment_approvers
    }
  }

  deployment_branch_policy {
    protected_branches     = false
    custom_branch_policies = true
  }
}

resource "github_repository_environment_deployment_policy" "this_branch_only" {
  repository  = var.repository_name
  environment = github_repository_environment.default.environment

  branch_pattern = local.branch_name
}

Steps to Reproduce

Use the above configuration with the requirement_deployment_approval var set to true, and an appropriate array of team ids in the github_deployment_approvers var (a single entry is fine), attached to a repository.

Apply.

Update the requirement_deployment_approval var to false.

Apply.

Debug Output

Panic Output

Code of Conduct

  • I agree to follow this project's Code of Conduct

Metadata

Metadata

Assignees

Labels

Type: BugSomething isn't working as documented

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions