Open giulianozor opened 3 years ago
We are experiencing exactly the same problem. Even after the resource is destroyed by terraform, the problem still occurs.
Experiencing the same thing. Specifically at the reviewers
argument in the resource github_repository_environment
.
resource "github_repository_environment" "production_environment" {
environment = "Production Environment"
repository = github_repository.repository.name
reviewers {
teams = var.prod_deploy_review_teams
users = var.prod_deploy_review_users
}
deployment_branch_policy {
protected_branches = true
custom_branch_policies = false
}
}
After running terraform apply -auto-approve
for the first time, terraform says it has successfully created the resources. However, when you check GitHub's environments, the required reviewers is checked but the users and teams are not added to the reveiwers list.
Now, when you run terraform apply -auto-approve
the second time, the error as the author post suggested occur.
Error: Provider produced inconsistent result after apply
When applying changes to
module.webapp-repository.github_repository_environment.production_environment,
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.
However, if you check GitHub again, the reviewers are now properly added into the environment.
Now, if you run terraform apply -auto-approve
a third time. No errors occur with a message saying that there are no infrastructure changes.
EDIT
If I were to put in the argument depends_on
and ensure that the teams that are to review the system be created before adding them as reviewer, then this error would not occur.
I'm not sure if this is related to the above.
Essentially, from:
resource "github_repository" "repository" {
name = var.name
description = var.description
}
resource "github_team_repository" "repository_teams" {
repository = github_repository.repository.name
team_id = var.team_id
permission = "push"
}
resource "github_repository_environment" "environment" {
environment = "some-environment"
repository = github_repository.repository.name
reviewers {
teams = [github_team_repository.repository_teams.team_id]
}
deployment_branch_policy {
protected_branches = true
custom_branch_policies = false
}
depends_on = [
github_team_repository.repository_teams,
]
}
I feel this might have some relation, so dropping it here.
EDIT
Never mind. Despite my depends_on
above, it still fails on me if I were to update an existing resource as per the below comments.
We are experiencing the same kind of problem. When adding the reviewers, only the first team in our list is added.
The subsequent terraform apply
produces the error. No matter how many time we call it, we still have the error.
With the depends_on
workaround mentioned by @JustinYeoh93 it works for me if I create all involved resources at once.
But if I try to add a reviewers team to an existing github_repository_environment
it requires two terraform apply
runs:
However any try to remove a team does not recover. The first terraform apply
run again applies the changes but thows the error:
Terraform will perform the following actions:
# module.repo.github_repository_environment.dev will be updated in-place
~ resource "github_repository_environment" "dev" {
id = "repo:dev"
# (2 unchanged attributes hidden)
- reviewers {
- teams = [
- 22,
] -> null
- users = [] -> null
}
# (1 unchanged block hidden)
}
Any subsequent terraform apply
run tries to remove the reviewers again and the error persists:
Error: Provider produced inconsistent result after apply
When applying changes to module.repo.github_repository_environment.dev, provider "provider[\"registry.terraform.io/integrations/github\"]" produced an unexpected new value: Root resource was present, but now absent.
We're also experiencing the same problem. We can't use the workaround with the depends_on at this point in time, so using this provider is blocking our progress.
is this going to get fixed anytime soon?
we've been using the following workaround but that's obviously not great for making changes:
resource "github_repository_environment" "foo" {
...
lifecycle {
ignore_changes = [reviewers]
}
}
👋 Hey Friends, this issue has been automatically marked as stale
because it has no recent activity. It will be closed if no further activity occurs. Please add the Status: Pinned
label if you feel that this issue needs to remain open/active. Thank you for your contributions and help in keeping things tidy!
After 20 months, I suppose this will never be fixed :(
32 months and 2 weeks bump... any news about this ?
thanks
happy third anniversary!
any update on this?
Just ran into this issue. 3 years running, nice! 😆 Seems like it isn't a prio for the maintainers – someone from the community is probably going to have to look into it. 🤷🏻♂️
I am on a free github plan, repo is public
Terraform Version
Affected Resource(s)
github_repository_environment
Terraform Configuration Files
Debug Output
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:
terraform apply
(without reviewers) > that runs fineterraform apply
(after adding the reviewers in the cconfig) > that gives the errorUpdate: 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