Repository navigation
feat(terraform): open a recovery pull request after a failed apply - #398
Merged
Merged
Conversation
A failed apply pushes terraform-recover/<stack> with the run URL in <stack>/recover.tf and opens a draft PR, so the leftover changes get a reviewed plan and apply on merge instead of an unreviewed recover. Opt-in through the recovery-token secret. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
tobias0106
marked this pull request as ready for review
November 9, 2026 11:37
tobias0106
requested review from
chandrashekar-dhar
and removed request for
a team
November 9, 2026 11:37
joscdk
approved these changes
Nov 10, 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.
Why
After a failed apply, the only way back is
command: recover, which plans and applies in one job without anyone reviewing the plan (monta-app/terraform#440). Environment approvals would fix that, but they aren't available for private repos on our GitHub plan.What
A new optional secret on
terraform-stack.yml,recovery-token. When it's set and an apply fails, the workflow:terraform-recover/<stack>from the default branch and writes the failed run URL into<stack>/recover.tf. It uses the contents API, so the runner needs no git credentials. If a recovery PR is already open, it adds a commit to that PR and doesn't reset the branch.terraform-failedissue and changes the issue's "next step" text to point at it.Any successful apply of the stack closes the open recovery PR.
Callers that don't pass the secret behave exactly as before.
Caveats
GITHUB_TOKEN, because PRs it opens don't trigger workflows. The token needs contents and pull-request write access on the caller repo.recoveris still the way out.bash -n. The first real failure in monta-app/terraform will be the actual test.🤖 Generated with Claude Code