Repository navigation
Let the workflow give the backend type - #445
Open
benlangfeld wants to merge 1 commit into
Open
benlangfeld wants to merge 1 commit into
benlangfeld wants to merge 1 commit into
Conversation
Working out the backend type means parsing every file in the root module, which costs most of a minute on a large one. Most workflows know the answer already and it rarely changes. Offer the existing backend_type input on plan, apply and check, and skip the inspection when it is set. The input is already defined for remote-state, so this reuses it rather than adding another. The log distinguishes the two cases, since a type that was given by the caller was not detected. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This was referenced Sep 23, 2026
benlangfeld
marked this pull request as ready for review
September 23, 2026 14:38
benlangfeld
marked this pull request as draft
September 23, 2026 14:41
benlangfeld
marked this pull request as ready for review
September 23, 2026 14:44
This branch has not been deployed
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.
One of the two approaches offered in #443. The other is #444, which makes the inspection itself cheap. They are independent — this one needs the caller to opt in, #444 helps everyone — and either stands alone.
The change
setup()works out the backend type by parsing every file in the root module. Most workflows know the answer already, and it rarely changes.When set, the inspection is skipped:
The log distinguishes the two cases, since a type the caller gave was not detected.
Notes on the approach
backend_typeis already defined indocs-gen/inputs/and used byremote-state, so this reuses that input withrequired=Falserather than adding a second one with the same name. It sorts immediately afterpath, which is whereAction.assert_orderingalready expects it.Added to plan, apply and check — the three actions named in #443.
actions.shis shared, so extending it to the others is only a matter of listing the input on them; I have left that out rather than widen the diff, and am happy to add them if you would prefer it everywhere at once.Generated files are regenerated with
docs-gen/generate.py; the only change in them is the new input.Effect
On the root module profiled in #443 — ~260
.tffiles — this removes a 46 second step. For comparison, #444 takes the same work from 34.07s to 0.20s on a generated module of that shape, without needing the input.Tests
pytest tests --ignore=tests/github_pr_commentgives 147 passed with 2 failures and 7 errors, identical tomain— those need S3 and some environment variables I do not have.tests/github_pr_commentfails to collect identically before and after, on a missingTERRAFORM_ACTIONS_*variable.bash -n image/actions.shis clean under bash 5.A larger related saving
The same root module is parsed twice per step.
terraform-versioncallsload_module()on it in its own process, immediately beforeterraform-backenddoes.That the first one is a parse rather than the archive download is now measured rather than inferred: the reporter cached the archive with
actions/cacheand the time did not move at all, with gpg verification landing at the identical offset on a cold and a warm run. See #443 (comment).Together the two parses are around 80 seconds of a ~5m30s plan.
#446 removes the first one for workflows that pin an exact version, by taking the existing argument fast path in
main()whenTERRAFORM_VERSIONnames a version rather than a constraint — which also skips the release index fetch. With this PR and #446 together, a large root module with a pinned version parses nothing at all before terraform runs.🤖 Generated with Claude Code