agentleFS
hmctshmcts/claude/.claude/skills/terraform-validate/SKILL.md

terraform-validate

Skill1 starsChanged 7 months agoMITView on GitHub

Validate Terraform modules and configurations across CP infrastructure repos. Use when checking Terraform code, reviewing infrastructure changes, or verifying module consistency.

1 other project uses a version of this.

Adopted by

Most recently taken up by

The file

We split this skill into the rules it gives an agent

9 rules. About 0 are common, 5 are distinctive, and 4 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈5

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 4

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Every Terraform repo should have:

    line 30
  2. Very specific:

    Read all vars/*.tfvars files

    line 86
  3. Distinctive:

    Verify each environment defines the same set of variables

    line 87
  4. Distinctive:

    Check that production values are appropriately different from non-prod (e.g., larger SKUs, more replicas)

    line 89
  5. Very specific:

    Check module blocks for source references

    line 95
  6. Very specific:

    Verify module versions are pinned (not ref=main)

    line 96
  7. Distinctive:

    Check if newer versions of consumed modules are available

    line 97
  8. Distinctive:

    Verify required input variables are provided

    line 98
  9. Very specific:

    Read-only user for reporting (pgreadonly)

    line 139

≈ “Common” is an estimate: at least 1 in 5 of the 213,897 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Terraform Validate

Validates Terraform modules and configurations across CP infrastructure repositories for consistency, security, and best practices.

When to Use

  • User asks to "validate terraform", "check this module", "review infrastructure changes"
  • User is modifying a cpp-terraform-* or cpp-module-terraform-* repo
  • User wants to verify state backend configuration
  • User wants to check variable naming conventions across modules

Process

Step 1: Identify Module Type

PrefixTypePurpose
cpp-module-terraform-azurerm-*Reusable moduleShared building blocks consumed by other Terraform repos
cpp-terraform-azurerm-*Root moduleEnvironment-specific infrastructure provisioning
cpp-terraform-networkNetworkVNet, subnet, NSG, peering configuration
cpp-automation-terraformAutomationTerraform automation and orchestration

Step 2: Validate Structure

Every Terraform repo should have:

├── main.tf                    # Primary resource definitions
├── variables.tf               # Input variable declarations
├── outputs.tf                 # Output value declarations
├── versions.tf                # Provider and Terraform version constraints
├── README.md                  # Auto-generated by terraform-docs
├── .pre-commit-config.yaml    # Pre-commit hooks
├── .terraform-version         # tfversion pinning
└── vars/                      # Environment-specific tfvars (root modules only)
    ├── dev.tfvars
    ├── sit.tfvars
    ├── ste.tfvars
    ├── nft.tfvars
    ├── prp.tfvars
    └── prd.tfvars

Step 3: Validation Checks

Variable Declarations

  • All variables have description field
  • All variables have type constraint
  • Sensitive variables marked with sensitive = true
  • Default values only for optional variables
  • Variable names use snake_case

Resource Configuration

  • All resources have consistent tagging (environment, team, service)
  • Resource names follow CP naming convention: {resource-type}-{env}-{purpose}
  • No hardcoded values that should be variables
  • Lifecycle rules specified where appropriate (prevent_destroy for stateful resources)

State Backend

  • Backend configuration uses Azure Storage Account
  • Non-live state: samdvshared01 in RG-MDV-SHARED-01
  • Live state: sampdshared01 in RG-MPD-SHARED-01
  • State container names are unique per workspace

Security

  • No secrets in .tf files or .tfvars (use Key Vault references)
  • NSG rules follow least-privilege principle
  • Private endpoints used for Azure PaaS services
  • Managed identities preferred over service principals
  • No * in RBAC role assignments

Pre-commit Hooks

  • .pre-commit-config.yaml present
  • Hooks include: terraform-fmt, terraform-validate, terraform-docs, tflint
  • Hook versions are current

Step 4: Environment Consistency

For root modules with per-environment tfvars:

  1. Read all vars/*.tfvars files
  2. Verify each environment defines the same set of variables
  3. Flag any environment-specific variables missing from other environments
  4. Check that production values are appropriately different from non-prod (e.g., larger SKUs, more replicas)

Step 5: Module Dependency Check

For root modules that consume reusable modules:

  1. Check module blocks for source references
  2. Verify module versions are pinned (not ref=main)
  3. Check if newer versions of consumed modules are available
  4. Verify required input variables are provided

Step 6: Generate Report

## Terraform Validation Report: [module-name]

### Structure
- [✅/❌] Standard file layout
- [✅/❌] Pre-commit hooks configured
- [✅/❌] README auto-generated

### Variables
| Name | Type | Description | Sensitive | Default | Status |
|------|------|-------------|-----------|---------|--------|

### Security
- [✅/❌] No hardcoded secrets
- [✅/❌] Private endpoints used
- [✅/❌] Managed identities preferred

### Environment Consistency
| Variable | dev | sit | ste | nft | prp | prd |
|----------|-----|-----|-----|-----|-----|-----|

### Issues
- [severity] [description] — suggested fix

CP-Specific Infrastructure Patterns

AKS Clusters

  • System + Worker + Prometheus node pools
  • Azure CNI networking with Calico network policy
  • OIDC issuer enabled for workload identity
  • Cluster naming: {env}-cs{stack}cl{cluster}

PostgreSQL

  • Flexible Server (not single server)
  • Per-context databases (hearing_db, resulting_db, etc.)
  • Admin credentials from Key Vault
  • Read-only user for reporting (pgreadonly)

Service Bus

  • Per-environment namespace
  • Topics per bounded context
  • Dead-letter queues configured
  • Max delivery count and TTL set per subscription

Key Vault

  • Per-environment vaults
  • CSI driver for pod secret injection
  • Secret rotation enabled

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.