Repository navigation
Replies: 1 comment
Revision 1: answers to the open questionsThis revision applies the answers to all three open questions:
Because of the second answer, this proposal now builds on Proposal: the rebuild entry point. See Dependencies below. Each section below replaces the section of the same name in the post, or says which part of it changes. Everything else in the post is unchanged and still applies. Decisions
SummaryOnly the last line changes: For every module and root module, BackgroundOne item is added:
Proposed designThe toolThe last paragraph is replaced by: OpenTofu and TFLint run in a container, through Dagger. Each is a container image pinned by tag and digest, in one place in the repository, and Renovate keeps them current. OpenTofu's A rebuild applies each phase's root module in that container, and What TFLint readsThis section is new, and goes after The tool. Tested with TFLint 0.65.0, its bundled
TestsThe paragraph after the example is replaced by: Nothing measures test coverage. The checksThis section replaces the post's. Proposal: the rebuild entry point gets one more command: For every directory that holds
It also fails when any It touches no target and needs no credentials, so it runs through the entry point's helper that may cache, not The first story that lands a module adds the command, and runs it from FilesThe Design decisionsTwo decisions are added, and the one on TFLint is replaced. The rest stand.
DocumentationOnly the Infrastructure modules page changes: it shows how to run the checks locally with DependenciesThis section is new. This proposal now builds on Proposal: the rebuild entry point, whose command and container its checks run through. The charter's revision 3 lists it as depending only on the charter, so the charter's next revision records the change. Definitions and drills already build on both, so nothing else moves. Open questionsNone. This revision answers all three. ReferencesAdded:
|
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Note
Revision 1 answers all three open questions. Modules and root modules stay in
.tffiles, because TFLint skips.tofufiles without a word. OpenTofu and TFLint run in containers through Dagger, for the checks as for a rebuild, through a newrebuild checkcommand, so this proposal now builds on the rebuild entry point. Nothing measures test coverage. The rest of this post is unchanged.Note
Revision 1 of Proposal: the rebuild entry point makes the entry point a Dagger module, so the
rebuild checkcommand this proposal's revision 1 adds changes. It becomes that module's checks, whichdagger checkruns fromBuildandverify. They use z5labs/devex'sopentofumodule for format, validate and test, with TFLint added to its container. The module sets the OpenTofu and TFLint versions, anddagger.lockpins their digests instead of Renovate. A phase's root module moves fromphases/<part>/torebuild/phases/<part>/, still beside its Go. This proposal's next revision takes these up.Note
Wave 1 of Proposal: rebuilding infra from scratch, as amended by revision 3. It depends only on the charter. Proposal: definitions, values and secrets and Proposal: drills build on it. Revision 3 makes this proposal the owner of a module's tests.
Summary
Every piece of infrastructure the platform's phases apply is written for OpenTofu:
modules/. It configures no provider, and it's tested withtofu testagainst mocked providers, so its tests need no credentials.For every module and root module,
Buildrunstofu fmt -check,tofu validate, TFLint andtofu test.Background
cloud/held 13 Terraform modules for GCP and Cloudflare:hashicorp/google8.7.0 andcloudflare/cloudflare5.28.1;required_version;terraform fmt -recursive -check(terraform.yml).Proposed design
The tool
OpenTofu, pinned to one exact version. It reads the same language and the same providers the old modules used. There's no Terragrunt: Proposal: the rebuild entry point sequences the phases, and each phase applies its own root module.
The linter is TFLint, with its bundled
terraformruleset on the recommended preset, and thegoogleruleset for Google Cloud's provider.Every tool is pinned to an exact version in one place in the repository, and Renovate keeps it current.
A module
<provider>-<thing>:google-project,google-state-bucket,cloudflare-zone. A module that spans providers is named for the thing alone.versions.tfsays which provider versions the module works with, such as>= 8.7.0, < 9.0.0.validationblock.this, as the old modules did.source = "../../modules/google-project", never from a registry or a git ref.sensitive = true.A root module
Each phase's root module lives in the phase's directory,
phases/<part>/, the path Proposal: the rebuild entry point gives each phase. It follows every module rule except two:.terraform.lock.hclwith hashes for every platform a rebuild runs on:linux_amd64,linux_arm64anddarwin_arm64.Its backend is the target's state backend, which Proposal: definitions, values and secrets provides. Only the rebuild applies a root module.
Tests
Every module and root module has tests in
tests/, andtofu testruns them:mock_provider, so no test reaches a real API or needs a credential.command = plan, and assert on the planned values.validationblock has a test that expects it to fail.OpenTofu has no coverage tool.
Buildfails a module or root module that has notests/directory, and review holds each one to the rules above.The checks
For every directory that holds
.tffiles,Buildruns:tofu fmt -check -recursive;tofu init -backend=false, thentofu validate;tflint --recursive;tofu test.The first story that lands a module adds these to
Buildand toverifyin.claude/backlog.json.Another tool
A part that needs something other than OpenTofu, as Proposal: home-lab hosts may for a host's operating system, justifies the tool in its own proposal. Whatever it picks is held to the same four checks: a format check, validation, a linter, and tests without credentials.
Files
Design decisions
Drill
A module's drill is its tests, which run in
Buildon every pull request with no credentials, as in the example above. A root module's tests prove its wiring. The drill of its phase, in Proposal: drills, proves it against a real scratch target.The first module comes back with phase 0, in Proposal: definitions, values and secrets, and is drilled with it.
Documentation
docs/content/fundamentals/infrastructure-modules.md, weight 50): the tool, a module's shape and rules, root modules, tests, and how to run the checks locally. It's the last page of Fundamentals, so it links to the first page of The platform.What it replaces
cloud/: exact pins inside modules, no tests, and CI that checked only formatting.terraform.yml, which the reset deleted. Its check comes back inBuild, with three more.Open questions
encryptionblock? If it doesn't, OpenTofu-only blocks could go in.tofufiles, which OpenTofu reads. That holds only if TFLint skips.tofufiles, which needs testing. If neither works, is a second linter needed?Buildandverifyrun the checks in the containers the rebuild uses, through Dagger, so a check and a rebuild run the same OpenTofu? Or should they install the pinned versions directly?Buildchecks only thattests/exists. Should it also check that everyvalidationblock has a test that expects it to fail, so the rule is enforced rather than reviewed?Out of scope
References
cloud/tree before the resetAll reactions