Expected Behavior
I had a Terraform plan with the following two resources:
github_repository
github_repository_collaborators
I modified both github_repository.name and github_repository_collaborators.team
The plan showed the following:
! github_repository.this["my-repo"] will be updated in-place
! github_repository_collaborators.repository_teams["my-repo"] must be replaced
I applied and expected everything to work just fine.
Actual Behavior
- The GitHub repository was renamed.
- Terraform tried to update the collaborators on the repository, but since the repository had been renamed in the previous step, Terraform could no longer find it and threw the following error:
Error: DELETE https://api.github.com/orgs/<ORG_NAME>/teams/<TEAM_SLUG>/repos/<ORG_NAME>/<REPO_NAME>: 404 Not Found []
To avoid this issue, the GitHub Terraform provider should implement the following logic:
- Check if the Terraform plan is trying to modify the
github_repository.name attribute.
- If the plan is modifying the repository name, review all the other resources in the plan that reference that GitHub repository.
- Apply the changes to all the dependent resources first, and then apply the change to the
github_repository resource last.
This ensures that no resources will try to interact with a GitHub repository that no longer exists, as you've already updated all the references to the old repository name before actually renaming the repository in the final step.
Terraform Version
v1.9.8
Affected Resource(s)
github_repository
github_repository_collaborators
Terraform Configuration Files
No response
Steps to Reproduce
No response
Debug Output
No response
Panic Output
No response
Code of Conduct
Expected Behavior
I had a Terraform plan with the following two resources:
github_repositorygithub_repository_collaboratorsI modified both
github_repository.nameandgithub_repository_collaborators.teamThe plan showed the following:
I applied and expected everything to work just fine.
Actual Behavior
To avoid this issue, the GitHub Terraform provider should implement the following logic:
github_repository.nameattribute.github_repositoryresource last.This ensures that no resources will try to interact with a GitHub repository that no longer exists, as you've already updated all the references to the old repository name before actually renaming the repository in the final step.
Terraform Version
v1.9.8
Affected Resource(s)
github_repositorygithub_repository_collaboratorsTerraform Configuration Files
No response
Steps to Reproduce
No response
Debug Output
No response
Panic Output
No response
Code of Conduct