gh-files-set: preserve user-managed files on terraform destroy#1107
Draft
Copilot wants to merge 2 commits intofeat/969-poc-gh-files-setfrom
Draft
gh-files-set: preserve user-managed files on terraform destroy#1107Copilot wants to merge 2 commits intofeat/969-poc-gh-files-setfrom
Copilot wants to merge 2 commits intofeat/969-poc-gh-files-setfrom
Conversation
Co-authored-by: alambike <1025564+alambike@users.noreply.github.com> Agent-Logs-Url: https://github.com/prefapp/tfm/sessions/3e65b55a-8b03-4042-a3cb-d4f168e78132
Copilot
AI
changed the title
[WIP] [WIP] Address feedback on user-managed files in gh-files-set module
gh-files-set: preserve user-managed files on terraform destroy
Mar 21, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
github_repository_filealways calls the GitHub delete API on destroy —lifecycle { ignore_changes = [content] }only suppresses content drift, it does not prevent file deletion.terraform destroywould wipe user-managed files from GitHub.Changes
main.tf: Replacegithub_repository_file.user_managedwithterraform_data+local-execprovisionerterraform_datahas no built-in destroy action; without awhen = destroyprovisioner,terraform destroyremoves the state entry only — the GitHub file is untouchedPUT /repos/{owner}/{repo}/contents/{file}viacurl+$GITHUB_TOKENon create/re-provisionoverwrite_on_create: fetches current SHA and skips or updates accordinglytriggers_replace = [file, branch]— content drift is intentionally ignored; only path or branch change re-provisionspython3→sedfallback);jq→grep/sedfallback for SHA extraction; API errors surfaced to stderrREADME.md/docs/header.md: Document preserve-on-destroy behavior; addGITHUB_TOKENenv var requirement (same token as the provider); update resource table toterraform_data.user_managed_examples/basic/files.yaml: Remove invalidlifecycle: {}field; add auserManaged: trueexample entry✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.