-
Notifications
You must be signed in to change notification settings - Fork 763
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
github_repository_file cant update/overwrite existing files. #438
Comments
Hi @techdragon, thank you for submitting this issue! looking at the logs you've provided it does look like the provider is behaving as expected at I do agree though that the error provided back to the user could be more detailed -- it looks like the Github API determines the file exists and attempts to do an update behind the scenes, but fails without a known |
@anGie44 thanks for digging in and working out the extra details that are going on with the GitHub API behind the scenes. I think a full resolution to the issue as it stands, needs to deal with two major details.
|
@techdragon thanks for sharing your use case and highlighting the incompatibility between template use and repository file management. I've been playing around with this locally and aim to push up a proposed fix that adds an |
Traditionally Terraform only manages what it knows about, so expecting it to update something it didn't create feels a bit unfair. I've seen a similar use case in other providers/resources and they will also generate an error that the resource already exists (we could catch the returned error and make it more user friendly though). IMO the solution here is to import the file into the state using |
Terraform Version
Terraform v0.12.23
Affected Resource(s)
github_repository_file
Terraform Configuration Files
( I unfortunately had to use a raw file like this due to hashicorp/terraform#23322, specifically that
yamlencode
doesnt support multiline blockkey-name: |
type strings. But the content of the file should not matter for this particular bug. )Debug Output
Complete terraform log not provided for security reasons. The relevant section of the log, with a small security redaction is here. This shows both the output sent to and the response from GitHub, so I hope this is sufficient.
https://gist.github.com/techdragon/ed73032aa5ab062674886a6c7478935e
Expected Behavior
github_repository_file
should be able to update files that already exist.Actual Behavior
Terraform fails to update an existing file in a github repository.
Steps to Reproduce
terraform apply
using agithub_repository_file
for the first time on a file that is already in the git repo.Important Factoids
"sha" wasn't supplied
directly from the upstream GitHub API. Either handling this, switching to update and "doing what the user wanted", or by emitting a more user friendly error message informing the user that they should import the resource first.References
The text was updated successfully, but these errors were encountered: