feat(opentofu): add init-backend input for credential-free lint jobs - #72
Merged
Conversation
A fmt/validate-only job on a configuration that has a `backend` block cannot run `tofu init` bare: the S3 backend resolves credentials during init, so the job dies with "No valid credential sources found" before `validate` is ever reached. The configuration is fine; the job simply has no business holding state-write credentials to lint HCL. `init-backend: false` passes `-backend=false`, which initialises providers and modules and skips the backend entirely. Default stays `true`, so every existing caller produces a byte-identical command line. Setting it alongside `run-plan: true` is a contradiction — plan needs state — so that combination now fails fast with an explicit error rather than surfacing as a confusing failure two steps later. Prompted by hordialabs/platform moving its OpenTofu state to Cloudflare R2: three stacks that had been linting green on local state went red the moment the backend blocks landed. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_017EDkXRcCrVDfu2e8V9Yy52
3 tasks
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.
Summary
A fmt/validate-only job on a configuration that has a
backendblock cannot runtofu initbare — the S3 backend resolves credentials during init, so the job dies withNo valid credential sources foundbeforevalidateis ever reached. The configuration is fine; the job simply has no business holding state-write credentials in order to lint HCL.init-backend: falsepasses-backend=false, which initialises providers and modules and skips the backend entirely.Surfaced by
HordiaLabs/platformmoving its OpenTofu state to Cloudflare R2 (HordiaLabs/platform#26): three stacks that had been linting green on local state went red the moment the backend blocks landed. No Linear issue.Changes
.github/workflows/opentofu.ymlinit-backendboolean input, defaulttrue.init-backend: falsetogether withrun-plan: trueis a contradiction (plan needs state), so it now fails fast with an explicit::error::rather than surfacing as a confusing failure two steps later.CHANGELOG.md— entry under[Unreleased].examples/README.md— lint-only example alongside the existing OpenTofu one.No new dependencies.
Test Plan
actionlintclean across the repoyamllintclean on the changed workflowtofu initagainst an R2backend "s3"with no credentials →No valid credential sources foundtofu init -backend=false && tofu validate→Success! The configuration is valid.on all three platform stacksHordiaLabs/platformonce this is releasedNotes for Reviewers
Default is
true, so every existing caller produces a byte-identical command line — the new flag is only appended when explicitly set tofalse. That is the main thing to check.Needs a
v3.2.0tag after merge:HordiaLabs/platform#26pins@v3and passes this input, so it stays red until the floatingv3tag moves.I did not backport to the
v2line. The release process is tag-from-main,v3is the current line, and this is a new feature rather than a fix — but say the word ifv2.18.0is wanted too, since most consumers are still on@v2.🤖 Generated with Claude Code
https://claude.ai/code/session_017EDkXRcCrVDfu2e8V9Yy52