← LeaderboardThe Skill Leaderboard

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.

Published by sickn33 ↗sickn33/agentic-awesome-skills

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 (count vs. for_each), variables, and testing frameworks while mentioning terraform init # Creates .terraform.lock.hcl once with no multi-platform -platform mirror 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.hcl includes 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.hcl hashes = [...] arrays do not map individual h1: hashes to specific platforms or prove upstream publisher signatures.
  • Do not use this skill to run terraform apply, terraform plan against live cloud state, execute untrusted provider plugins, parse untrusted Terraform modules, or overwrite production .terraform.lock.hcl files.
  • Scope configuration inputs strictly to trusted synthetic required_providers declarations (reject module blocks and remote sources).

Prerequisites

  • Official terraform CLI (terraform version, tested on v1.17.2) on PATH or pointed to by TERRAFORM_BIN.
  • Python 3.10+ with lark (lark==1.3.1) and pytest (tested with Python 3.12.10, lark==1.3.1, and pytest==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

  1. Parse .terraform.lock.hcl using a structured lark HCL lockfile grammar (handling #, //, and /* ... */ comments cleanly and rejecting malformed/trailing HCL tokens as INVALID_INPUT) combined with Terraform-native lockfile validation.
  2. Validate non-empty explicit platforms, required_providers source addresses/versions, and synthetic configuration scope (rejecting module blocks). Every required provider must exist in .terraform.lock.hcl with matching version and non-empty hashes (MISSING_LOCK_PROVIDER / VERSION_MISMATCH / EMPTY_LOCK_HASHES).
  3. Enforce the lockfile platform-identity limit: .terraform.lock.hcl stores an unlabeled hashes = ["h1:...", ...] list; reading .terraform.lock.hcl alone cannot determine which h1: belongs to linux_amd64 vs. 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:

  1. Multi-platform lock generation & parity check: Copy the trusted synthetic versions.tf and candidate .terraform.lock.hcl into isolated temporary directories (stripped TF_* environment, local.tfrc disabling checkpoint calls), execute terraform providers lock -no-color -fs-mirror=<mirror> -platform=<p1> ... (30s timeout), verify the generated provider set matches required_providers (GENERATED_PROVIDER_MISMATCH), require non-empty generated hashes, and compare the generated h1: hash set against the candidate lockfile.
  2. Missing CI platform package: Omit one required platform (darwin_arm64) from the filesystem mirror and confirm terraform providers lock exits non-zero (MISSING_PLATFORM_PACKAGE).
  3. Altered mirror archive / checksum mismatch: Modify a mirror provider .zip after baseline lock generation and verify terraform providers lock yields a new h1: hash set diverging from the baseline lockfile (CHECKSUM_MISMATCH).
  4. Trust boundary separation: Report (unauthenticated) mirror retrievals explicitly: local -fs-mirror checksum 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-mirror lock operations compute h1: 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 lock offline requires every target platform archive to exist in the configured -fs-mirror directory.
  • 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 lock solely inside disposable tempfile.TemporaryDirectory copies with synthetic dummy binary payloads (never runs init -plugin-dir execution, plan, or apply).

Sources and related skills