Files
gcp_solution_architecture_a…/skills/iac-validation/SKILL.md
Jonathan Boniface ef37f59bad feat: opt-in published Terraform modules from approved sources (iteration 8)
Infrastructure code is plain resources by default. An Execution may opt in
with terraform_modules; the deployment default is TERRAFORM_MODULES, off.

- A module is accepted only from the registry namespaces the provider bundle
  lists (terraform-google-modules), at one exact version. Any other source is
  refused before Terraform runs; until now nothing stopped generated code
  naming any source for terraform init to download.
- terraform_module looks up a module's inputs, outputs and submodules from
  the registry and says when it cannot be used with the pinned provider.
- skills/google-cloud-iac-modules: when a module fits, and four modules with
  examples a test validates against hashicorp/google 8.6.0.
- Opted in, the IaC author and validator get the Skill and the lookup. Not
  opted in, they get neither and a module block is refused in code.
- A Change request follows its Baseline. execution.json records the choice.
- case-07 runs case 03's request with modules opted into.

Azure (aztfm) and AWS (terraform-aws-modules) sources are recorded in the
plan for when those Cloud providers are added. No case has run with this.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-09 22:09:29 +01:00

4.1 KiB

name, description, metadata
name description metadata
iac-validation Checks Terraform infrastructure-as-code without provisioning anything, using the local terraform_fmt, terraform_validate, terraform_plan and terraform_schema tools. Use when writing deployment guidance or validating it before deployment.
scope
deployment-guidance validation

IaC validation

Every check runs on a scratch copy of your Terraform files. Nothing is applied, and no state is written.

The files are your working copy: the files you wrote with write_file, or, when you are validating, the files that were submitted. Pass the tools no files.

Tools

  • terraform_fmt(): formats your working copy in place and names the files it changed.

  • terraform_validate(): runs init -backend=false and validate offline. It reports syntax errors, unknown references, missing variables and invalid arguments.

  • terraform_plan(variables): previews the changes against the live cloud environment. It reads live state, so the first call may pause for the user's permission. Pass every variable the configuration requires.

  • terraform_schema(resource_type, block, find, resource_types): what a resource type accepts, from the provider's own schema. With resource_types, a list, it outlines every argument and block of each in one call; use that when you need several. With resource_type alone it lists the top-level arguments and outlines every block. With block, such as template.containers, it gives that block's arguments in full. With find, it says where an argument or block of that name sits, or that the resource type has none; give several names separated by commas to check them in one call.

  • terraform_module(source, version, find), only when the Execution opted into published modules: what a published module accepts, from the registry: its inputs with their types, its outputs and its submodules. It says when a module cannot be used with the pinned provider. find narrows the inputs to those matching the words given. Only modules from the namespaces the Cloud provider allows can be looked up or used.

When writing deployment guidance

  1. Run terraform_fmt, then terraform_validate.
  2. Fix each error with edit_file, changing only the lines concerned, and run terraform_validate again until it passes.
  3. A refusal about a module means one of two things. The Execution writes plain resources, so write them directly. Or the module is not from an approved namespace or not pinned to one exact version, so use an approved module at an exact version or write the resources directly.
  4. On "An argument named X is not expected here" or "Unsupported block type", call terraform_schema with find set to the name. It is either in a different block, which the reply names, or it does not exist on that resource type. Never move it around by trial.

When validating deployment guidance

  1. Run terraform_validate, and report its verdict and output.

  2. When permission to read the live environment is granted, run terraform_plan with the variable values from the requirements, or clearly marked placeholders. Summarise the resources to add, change and destroy, and flag any destroy or replace.

  3. When a check can't run (a missing CLI, a refused permission or a provider download failure), give the user the exact commands to run themselves:

    terraform init -backend=false
    terraform validate
    terraform plan -lock=false -var-file=<your.tfvars>
    

Reporting verdicts

Give a verdict on every Check in the Target architecture. Record them with verdict_put, a few Checks per call; they are attached as verdicts.json, in the format the requirements-chain Skill gives, when you submit. The dry-run's result goes in its dry_run entry: pass when terraform_validate passes, fail with the error when it does not, and not_run when the tool could not run.

A Check fails when the code could meet it and does not. When terraform_schema shows the resource type has no such setting, no code could meet it: the verdict is not_verifiable, with the schema's answer as evidence.

Never suggest terraform apply as part of validation.