Skip to content
Back to skills

Terraform Provider Lock Platform Audit

ASecurity

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.

  • 50,717 stars
  • 0 votes
  • 0 copies
  • 1 view
  • Added December 2, 2026
ai-agentspythonrustgoterraformtestinggitdevops

Works with

  • cli

Security analysis

A100/100

Pro scans all 2 files and shows the line behind each finding

Scanned December 2, 2026

npx -y skills add sickn33/agentic-awesome-skills --skill terraform-provider-lock-platform-audit --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Terraform Provider Lock Platform Audit?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Terraform Provider Lock Platform Audit
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/sickn33-terraform-provider-lock-platform-audit/badge)](https://www.skillsdirectory.com/skills/sickn33-terraform-provider-lock-platform-audit)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: terraform-provider-lock-platform-audit
description: "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: devops
risk: safe
source: self
source_type: self
date_added: "2026-12-01"
author: Koushik-Katkam
tags: [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](references/terraform-lock-audit-harness.md):

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](references/terraform-lock-audit-harness.md):

```text
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

- [Terraform Docs — `terraform providers lock`](https://developer.hashicorp.com/terraform/cli/commands/providers/lock)
- [Terraform Docs — Dependency Lock File](https://developer.hashicorp.com/terraform/language/files/dependency-lock)
- Related skills: [terraform-skill](https://github.com/sickn33/agentic-awesome-skills/blob/e4dcf3977b6d1e18a2539f630bd82c2433d283e2/skills/terraform-skill/SKILL.md), [opentofu-migration](https://github.com/sickn33/agentic-awesome-skills/blob/e4dcf3977b6d1e18a2539f630bd82c2433d283e2/skills/opentofu-migration/SKILL.md).

Files in this skill

  • SKILL.md7.4 KB
  • references/terraform-lock-audit-harness.md21.1 KB

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

View all in ai-agents →

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.