-
Notifications
You must be signed in to change notification settings - Fork 861
Closed as not planned
Closed as not planned
Copy link
Labels
Status: StaleUsed by stalebot to clean houseUsed by stalebot to clean houseStatus: Up for grabsIssues that are ready to be worked on by anyoneIssues that are ready to be worked on by anyoneType: BugSomething isn't working as documentedSomething isn't working as documented
Description
Expected Behavior
Expected to see the branch
argument populated with the Terraform state file and that the plan would not force replace the resource.
Actual Behavior
The Terraform state file recorded the branch
as null. When a terraform plan
occurs after the import, Terraform wants to force replace the resource.
# github_repository_file.readme must be replaced
# (imported from "test-import/README.md")
# Warning: this will destroy the imported resource
-/+ resource "github_repository_file" "readme" {
+ branch = "main" # forces replacement
~ commit_message = "Initial commit of the module" -> "chore: Update repository scaffolding"
~ commit_sha = "10d7666466de45cf1d2468bb4c201d8edb752b28" -> (known after apply)
~ id = "test-import/README.md" -> (known after apply)
~ overwrite_on_create = false -> true
~ ref = "main" -> (known after apply)
repository = "test-import"
~ sha = "c05f3f5777527c4f852f9f03d3f83gh18671a01f" -> (known after apply)
}
Looking at the import logic, it only seems to set the branch if you import specifying the branch (ie with a :
). However, when I do specify the branch within the import (ie test-import/README:main
as the ID in the CLI or import configuration) it still shows as a force replacement.
The logic should set the branch if the default branch is being used explicitly.
Terraform Version
Terraform v1.6.3
integrations/github v5.42.0
Affected Resource(s)
- github_repository_file
Terraform Configuration Files
import {
id = "testorg/README.md"
to = "github_repository_file.readme"
}
resource "github_repository_file" "readme" {
repository = "test-import"
branch = "main"
file = "README.md"
content = "I'm a README file"
commit_message = "testing import"
commit_author = "test"
commit_email = "test@test.com"
overwrite_on_create = true
}
Steps to Reproduce
- Import a file off of the repository's default branch (ie main). This can be done either with the Terraform CLI using
terraform import github_repository_file.readme testorg/README.md
or the Terraform import configuration. - Run a
terraform plan
Debug Output
No response
Panic Output
No response
Code of Conduct
- I agree to follow this project's Code of Conduct
chris3ware
Metadata
Metadata
Assignees
Labels
Status: StaleUsed by stalebot to clean houseUsed by stalebot to clean houseStatus: Up for grabsIssues that are ready to be worked on by anyoneIssues that are ready to be worked on by anyoneType: BugSomething isn't working as documentedSomething isn't working as documented
Type
Projects
Status
✅ Done