@intentius/chant-lexicon-terraform
v0.79.0
Published
terraform lexicon for chant, existing Terraform root modules as declarable entities
Downloads
4,591
Readme
@intentius/chant-lexicon-terraform
Terraform lexicon plugin for chant.
Unlike the lexicons that generate typed resource classes from an upstream
schema, this one reads the HCL an estate already has. Name your root modules in
chant.config.ts and each .tf block joins the build as an entity, so the
post-synth checks and chant audit can see the root without anything being
written back over it.
// chant.config.ts
import type { ChantConfig } from "@intentius/chant/config";
import "@intentius/chant-lexicon-terraform";
export default {
lexicons: ["terraform"],
terraform: {
binary: "terraform", // or "tofu"
roots: {
app: { dir: "./terraform", workspace: "prod", varFiles: ["prod.tfvars"] },
},
},
} satisfies ChantConfig;dir resolves against the project root, the directory holding
chant.config.ts. A root that does not exist, or a .tf the parser refuses, is
a build warning and no entities for that root, never a failure.
Getting started
# Assemble dist/ (there is no upstream spec to fetch)
npm run bundle
# Validate the generated artifacts
just validate
# Generate the docs site
just docsProject structure
src/plugin.ts, the LexiconPlugin, including thebuildRoots()hooksrc/config.ts, theterraformconfig namespace and itsChantConfigaugmentationsrc/hcl/parse.ts, one entity per HCL block, from a directory or fromchant audit's joined-file formsrc/hcl/roots.ts, the per-root renderbuildRoots()delegates tosrc/serializer.ts, a deliberate no-op: the.tffiles are the artifactsrc/lint/rules/, source-level lint rulessrc/lint/post-synth/, checks over the parsed roots (TF001 and up)src/lsp/, LSP completions and hover
Acceptance evidence
Four describe blocks run this lexicon against a real terraform, tofu or
choudoufu binary, and each of them skips rather than fails when its
dependency is absent. src/__fixtures__/ACCEPTANCE.md records, per block,
what it proves, what gates it, the command that runs it, and the last binary
and emulator it passed against with the date. Two of the four have never
passed against anything, and that file says so.
