-
Couldn't load subscription status.
- Fork 878
Description
Hello,
I'm having issues trying to remove/destroy github repo's by either using terraform destroy or after removing a module from the code and doing a terraform plan on repo's which are archived. I have several archived repo's which i want to delete, but that isn't possible using terraform only right now when the archived flag is set to true. It complains about some resources that arn't able to be modified because the archive is in read-only state.
Terraform Version
Terraform v1.0.3
on linux_amd64
+ provider registry.terraform.io/gitlabhq/gitlab v3.7.0
+ provider registry.terraform.io/hashicorp/aws v3.52.0
+ provider registry.terraform.io/hashicorp/null v3.1.0
+ provider registry.terraform.io/integrations/github v4.13.0
Affected Resource(s)
At least the following, could be more:
- github_repository_collaborator
- github_repository
Terraform Configuration Files (as a module)
resource "github_repository" "repository" {
name = var.name
description = var.description
visibility = var.visibility
has_issues = var.issues
has_wiki = false
auto_init = var.auto_init
allow_squash_merge = var.allow_squash_merge
allow_rebase_merge = var.allow_rebase_merge
allow_merge_commit = var.allow_merge_commit
delete_branch_on_merge = var.delete_branch_on_merge
topics = var.topics
archived = var.archived
}
resource "github_repository_collaborator" "cicd-deployer_ro" {
count = var.allow_cicd-deployer_to_push == "true" ? 0 : 1
repository = github_repository.repository.name
username = "cicd-deployer"
permission = "pull"
}
resource "github_repository_collaborator" "cicd-deployer_rw" {
count = var.allow_cicd-deployer_to_push == "true" ? 1 : 0
repository = github_repository.repository.name
username = "cicd-deployer"
permission = "push"
}Debug Output
Not able to provide actual debug output here, but the following line should be enough.
Error: DELETE https://api.github.com/repos/OWNER/REPO/collaborators/cicd-deployer: 403 Repository was archived so is read-only. []
Panic Output
n/a
Expected Behavior
Repository is deleted from github and nicely cleaned from terraform state.
Actual Behavior
The github provider returns an error that a specific resource is not being able to be deleted because the repository is set to read-only. If i manually delete the repo via github api call it works fine and all linked resources are removed by github.
Steps to Reproduce
Please list the steps required to reproduce the issue, for example:
- Use something like the above provided code.
- Have a
github_repositoryand agithub_repository_collaboratorboth configured.
terraform apply- Configure that repo to be archived via the
archivedflag. terraform apply- Either comment out that repo or use
terraform destroyto remove that module. - It will error out because the repo is read-only and removing collaborators isn't possible.
Important Factoids
Non as far is a know, it happens at least on private repo's since that is where this is configured on.
References
n/a
Metadata
Metadata
Assignees
Labels
Type
Projects
Status