terraform-provider-lock-platform-audit
Audit .terraform.lock.hcl files and multi-platform CI matrices offline with pinned Terraform providers lock and synthetic filesystem mirrors across checksums and trust limits.
Try your first task
A source-grounded starter task has not been verified for this skill yet.
SKILL.md
name: terraform-provider-lock-platform-auditdescription: "Audit .terraform.lock.hcl files and multi-platform CI matrices offline with pinned Terraform providers lock and synthetic filesystem mirrors across checksums and trust limits."category: devopsrisk: safesource: selfsource_type: selfdate_added: "2026-12-01"author: Koushik-Katkamtags: [terraform, lockfile, providers, multi-platform, checksums, audit]Terraform Provider Lock Platform Audit
Overview
Audit Terraform .terraform.lock.hcl dependency lock files and CI platform matrices (linux_amd64, windows_amd64, darwin_arm64) offline using the real terraform providers lock -fs-mirror=... command in isolated temporary directories (Terraform v1.17.2) against local/synthetic filesystem provider mirrors. Verifies required provider source addresses and pinned versions, mirror package availability across every target platform, lockfile h1: hash integrity against mirror packages, missing platform failures, and altered package checksum mismatches — while never running terraform apply, executing provider binaries, or accessing remote state.
Distinction from existing IaC skills:
terraform-skill: teaches module design (countvs.for_each), variables, and testing frameworks while mentioningterraform init # Creates .terraform.lock.hclonce with no multi-platform-platformmirror audit or checksum tampering tests.opentofu-migration: guides migrating configurations from Terraform to OpenTofu (tofu init/plan) rather than auditing multi-platform lockfile checksum completeness against filesystem mirrors.
When to Use
- Verifying that
.terraform.lock.hclincludes package coverage for every OS/architecture in a team's CI matrix (linux_amd64,darwin_arm64,windows_amd64) using an approved local provider mirror. - Catching missing platform packages or altered/corrupted mirror provider ZIP archives whose recomputed
h1:checksum diverges from the locked hashes. - Explicitly documenting why flat
.terraform.lock.hclhashes = [...]arrays do not map individualh1:hashes to specific platforms or prove upstream publisher signatures. - Do not use this skill to run
terraform apply,terraform planagainst live cloud state, execute untrusted provider plugins, parse untrusted Terraform modules, or overwrite production.terraform.lock.hclfiles. - Scope configuration inputs strictly to trusted synthetic
required_providersdeclarations (rejectmoduleblocks and remote sources).
Prerequisites
- Official
terraformCLI (terraform version, tested onv1.17.2) onPATHor pointed to byTERRAFORM_BIN. - Python
3.10+withlark(lark==1.3.1) andpytest(tested with Python3.12.10,lark==1.3.1, andpytest==9.1.1). - No cloud credentials, remote Terraform state, registry network calls, or provider binary execution required.
How It Works
1. Audit declared providers vs. lockfile entries and platform limitations
- Parse
.terraform.lock.hclusing a structuredlarkHCL lockfile grammar (handling#,//, and/* ... */comments cleanly and rejecting malformed/trailing HCL tokens asINVALID_INPUT) combined with Terraform-native lockfile validation. - Validate non-empty explicit
platforms,required_providerssource addresses/versions, and synthetic configuration scope (rejectingmoduleblocks). Every required provider must exist in.terraform.lock.hclwith matching version and non-empty hashes (MISSING_LOCK_PROVIDER/VERSION_MISMATCH/EMPTY_LOCK_HASHES). - Enforce the lockfile platform-identity limit:
.terraform.lock.hclstores an unlabeledhashes = ["h1:...", ...]list; reading.terraform.lock.hclalone cannot determine whichh1:belongs tolinux_amd64vs.darwin_arm64— real multi-platform-platform=...verification against mirror packages is mandatory.
2. Exercise real terraform providers lock -fs-mirror=... in isolated temp workspaces
Run the local verification suite in Terraform lockfile platform audit harness:
- Multi-platform lock generation & parity check: Copy the trusted synthetic
versions.tfand candidate.terraform.lock.hclinto isolated temporary directories (strippedTF_*environment,local.tfrcdisabling checkpoint calls), executeterraform providers lock -no-color -fs-mirror=<mirror> -platform=<p1> ...(30stimeout), verify the generated provider set matchesrequired_providers(GENERATED_PROVIDER_MISMATCH), require non-empty generated hashes, and compare the generatedh1:hash set against the candidate lockfile. - Missing CI platform package: Omit one required platform (
darwin_arm64) from the filesystem mirror and confirmterraform providers lockexits non-zero (MISSING_PLATFORM_PACKAGE). - Altered mirror archive / checksum mismatch: Modify a mirror provider
.zipafter baseline lock generation and verifyterraform providers lockyields a newh1:hash set diverging from the baseline lockfile (CHECKSUM_MISMATCH). - Trust boundary separation: Report
(unauthenticated)mirror retrievals explicitly: local-fs-mirrorchecksum verification proves byte consistency between mirror archives and.terraform.lock.hcl(package_integrity), never upstream GPG signature trust or publisher provenance (upstream_trust_unverified).
Examples
Run the self-contained verification suite in Terraform lockfile platform audit harness:
User request: "Verify our .terraform.lock.hcl matches our mirror packages across linux_amd64, darwin_arm64, and windows_amd64."
Inputs: versions.tf, .terraform.lock.hcl, CI platform list, and local -fs-mirror directory run under Terraform v1.17.2.
Expected result: Clean 3-platform lockfile matches recomputed h1: hashes with PASS + unauthenticated-mirror caveat;
missing platform package fails terraform providers lock; altered mirror zip triggers CHECKSUM_MISMATCH;
missing lock provider/malformed HCL returns FAIL/INVALID_INPUT.
Limitations
-fs-mirrorlock operations computeh1:hashes only (Terraform's zip-unpacked directory hash) and explicitly report(unauthenticated)packages — they do not verify upstream registry GPG signatures (zh:origin registry verification) or remote module sources.- Running
terraform providers lockoffline requires every target platform archive to exist in the configured-fs-mirrordirectory. - Does not evaluate Terraform resource blocks, providers' runtime schemas, or
tofu(OpenTofu) behavioral differences.
Safety and Side Effects
- Strictly offline and read-only against caller workspaces: executes
terraform providers locksolely inside disposabletempfile.TemporaryDirectorycopies with synthetic dummy binary payloads (never runsinit -plugin-direxecution,plan, orapply).