terraform-provider-github
terraform-provider-github copied to clipboard
[BUG]: Changes made to repository's Github Pages configuration outside Terraform are not detected on terraform refresh
Expected Behavior
If a github_repository
resource has the pages
block configured and deployed, but then the repository's Github Pages configuration is subsequently changed outside of Terraform, the Github Terraform provider should detect those changes on the next terraform plan
/terraform apply
/terraform refresh
and update the underlying resource's configuration to what's reflected in the Terraform template.
Actual Behavior
If changes to a repository's Pages configuration are made outside Terraform those changes are not detected in the next terraform plan
/terraform apply
/terraform refresh
and instead shows the following output:
No changes. Your infrastructure matches the configuration.
Terraform has compared your real infrastructure against your configuration and found no differences, so no changes are needed.
Terraform Version
Terraform v1.5.7 on darwin_amd64
- provider registry.terraform.io/integrations/github v5.37.0
Affected Resource(s)
github_repository
Terraform Configuration Files
resource "github_repository" "main" {
name = "test-repo"
auto_init = true
pages {
source {
branch = "master"
path = "/docs"
}
}
}
Steps to Reproduce
- Deploy the
github_repository
resource shown above, which will enable Github Pages - In the Github console, change one or more of the Github Pages configuration items specified in the deployed Terraform resource
- Run
terraform apply
- Observe the
No changes. Your infrastructure matches the configuration
output.
Debug Output
No response
Panic Output
No response
Code of Conduct
- [X] I agree to follow this project's Code of Conduct
Following from this bug, removing the pages
config block on a github_repository
resource that has already had pages disabled in the Github console (ie outside of terraform) results in a 404 upon the next terraform apply
and thus a broken Terraform template/state:
Terraform will perform the following actions:
# github_repository.main will be updated in-place
~ resource "github_repository" "main" {
id = "test-repo"
name = "test-repo"
# (34 unchanged attributes hidden)
- pages {
- build_type = "legacy" -> null
- custom_404 = false -> null
- html_url = "https://redacted.pages.github.io/" -> null
- status = "building" -> null
- url = "https://api.github.com/repos/redacted/test-repo/pages" -> null
- source {
- branch = "main" -> null
- path = "/docs" -> null
}
}
# (1 unchanged block hidden)
}
Plan: 0 to add, 1 to change, 0 to destroy.
Do you want to perform these actions?
Terraform will perform the actions described above.
Only 'yes' will be accepted to approve.
Enter a value: yes
github_repository.main: Modifying... [id=test-repo]
│ Error: DELETE https://api.github.com/repos/redacted/test-repo/pages: 404 Not Found []
│
│ with github_repository.main,
│ on main.tf line 1, in resource "github_repository" "main":
│ 1: resource "github_repository" "main" {
│
╵
Releasing state lock. This may take a few moments...
I assume this error occurs because the resource's update method doesn't handle the 404 response.
I'm running into the same issue regarding Terraform not detecting changes made to GitHub Pages. Also, I am not sure why GitHub Pages is managed as a nested block instead of being a standalone resource, they are separate endpoints in the REST API and are controlled by separate permissions.
They definitely should be separate resources; see #1617 for a draft attempt at splitting them. It hasn't changed yet mostly due to inertia and the severity of the breaking change.