Terraform validation

From y-miyazaki/terraform-aws-base · View interactive version

Terraform validation is an AI agent skill from the GitHub repository y-miyazaki/terraform-aws-base. Validate Terraform syntax, linting, and security with terraform fmt/validate, tflint, and trivy. Use when committing Terraform changes, running CI validation, or checking IaC security issues.

How to use this skill

Skill file

Input

Output Specification

Return structured Markdown in accordance with references/common-output-format.md. That file is the source of truth for the output contract.

Structured results in the script's order: tflint, terraform validate, terraform fmt, argument order (with --check-order), trivy (trivy fs <target> --format table).

Execution Scope

USE FOR:

DO NOT USE FOR:

Reference Files Guide

Workflow

  1. Run bash scripts/validate.sh.
  2. For scoped runs, pass one or more target directories: bash scripts/validate.sh <terraform-dir>.
  3. Use --fix for formatting corrections and --verbose for diagnostics.
  4. Retry at most 2 times after fixes; if checks still fail, return blocking findings and stop.

Error Handling

| Condition | Severity | Action |

| --------------------------------------------------------------------------------------------------------------------------------- | ----------- | -------------------------------------------------------------------------------------------------------------------- |

| scripts/validate.sh missing | Fatal | Stop; report missing script |

| No .tf files under target path | Info | Report no reviewable Terraform; stop |

| Required binary missing (terraform, tflint, trivy; python3 with --check-order; terraform-docs with --generate-docs) | Fatal | Stop; report the missing binary; set Status: ❌ FAIL |

| --check-order fails with can't open file ... terraform_attr_order.py | Recoverable | Report argument order as ⊘ Skipped (helper not bundled), not as an ORD-01 violation; leave ORD-01 to manual review |

| Single tool fails, others succeed | Recoverable | Report every tool; mark the failed tool ❌ Fail with exit status |

| All tools fail | Fatal | Set Status: ❌ FAIL with per-tool stderr summaries in ## Error Details |

| common-checklist.md unavailable | Fatal | Stop; report missing dependency |

| common-output-format.md unavailable | Recoverable | Note missing file; emit ## Summary, ## Tool Results, and ## Error Details only |

Examples

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.