terraform-provider-github icon indicating copy to clipboard operation
terraform-provider-github copied to clipboard

github_repository_environment - Provider produced inconsistent result after apply

Open giulianozor opened this issue 3 years ago • 11 comments

I am on a free github plan, repo is public

Terraform Version

Terraform v1.0.0
on darwin_amd64
+ provider registry.terraform.io/integrations/github v4.12.0

Affected Resource(s)

github_repository_environment

Terraform Configuration Files


locals  {
environments_list_expanded = {
     test1.DEV = {repo ="test1", code="DEV",name="Development"}},
     test1.PROD = {repo ="test1", code="PROD",name="Production"}},
     test2.DEV = {repo ="test2", code="DEV",name="Development"}},
     test2.PROD = {repo ="test2", code="PROD",name="Production"}}
  }
}



resource "github_repository_environment" "environments" {
  for_each = local.environments_list_expanded
  environment   = each.value.name
  repository    = var.repo_name
  wait_timer = 10

  reviewers {
    users = [ var.user_id ]
  }

  deployment_branch_policy {
    protected_branches          = true
    custom_branch_policies      = false
  }
}

Debug Output

│ Error: Provider produced inconsistent result after apply
│
│ When applying changes to
│ github_repository_environment.environments["test2.DEV"], provider
│ "provider[\"registry.terraform.io/integrations/github\"]" produced an
│ unexpected new value: Root resource was present, but now absent.
│
│ This is a bug in the provider, which should be reported in the provider's
│ own issue tracker.

Expected Behavior

No error at all

Actual BehaviorUser was added to the reviewers, but terraform exited with the error above

Steps to Reproduce

Please list the steps required to reproduce the issue, for example:

  1. terraform apply (without reviewers) > that runs fine
  2. terraform apply (after adding the reviewers in the cconfig) > that gives the error

Update: It seems the error happens only from the 2nd apply. I have to destroy and apply and everything works fine

References

I have seen fixes for other resources in the past, but not tor this resource

giulianozor avatar Jun 25 '21 08:06 giulianozor