Skip to content
Back to skills

Using Terraform

ASecurity

Use when writing or editing Terraform 1.12+ infrastructure code. Triggers on `.tf` and `.tfvars` files, modules, remote state, per-environment setup, for_each, dynamic blocks, locals, or providers, even when the user doesn't say 'Terraform'.

  • 6 stars
  • 0 votes
  • 0 copies
  • 0 views
  • Added November 30, 2026
ai-agentsgoazureterraformbackend

Security analysis

A100/100

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

Scanned November 30, 2026

npx -y skills add xonovex/platform --skill using-terraform --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Using Terraform?

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

Security grade badge for Using Terraform
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/xonovex-using-terraform/badge)](https://www.skillsdirectory.com/skills/xonovex-using-terraform)

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: using-terraform
description: "Use when writing or editing Terraform 1.12+ infrastructure code. Triggers on `.tf` and `.tfvars` files, modules, remote state, per-environment setup, for_each, dynamic blocks, locals, or providers, even when the user doesn't say 'Terraform'."
---

# Terraform Coding Guidelines

Manage infrastructure through Terraform plans with pinned providers, protected state, and validated changes.

## Requirements

- Terraform ≥ 1.12; remote state; pinned providers; fmt/validate.

## Essentials

- **Module design** - One responsibility per module, clear inputs/outputs, typed variables, see [references/module-structure.md](references/module-structure.md), [references/module-definition.md](references/module-definition.md), [references/typed-variables.md](references/typed-variables.md)
- **Composition** - Thin root modules, compose child modules, use locals for computed values, see [references/root-module.md](references/root-module.md), [references/locals.md](references/locals.md)
- **Environment isolation** - Separate envs (dirs + tfvars), isolate state per env, see [references/root-module.md](references/root-module.md), [references/remote-state.md](references/remote-state.md)
- **Advanced patterns** - Data sources, dynamic blocks, see [references/advanced-patterns.md](references/advanced-patterns.md)

## Gotchas

- State file (`terraform.tfstate`) contains secrets in plaintext: store it remotely with encryption and backend-native locking (S3 `use_lockfile = true`; Azure Blob lease locking)
- `lifecycle { prevent_destroy = true }` blocks `terraform destroy` for that resource: useful for prod, painful in CI/test envs
- `terraform refresh` updates state from real infra but doesn't show what changed: use `terraform plan -refresh-only` to preview drift
- Provider version pinning lives in `required_providers`, not the resource block: unpinned providers break on minor upgrades

## Progressive disclosure

- Read [references/module-structure.md](references/module-structure.md) - Load when designing reusable Terraform modules
- Read [references/module-definition.md](references/module-definition.md) - Load when defining module inputs, outputs, or resources
- Read [references/typed-variables.md](references/typed-variables.md) - Load when adding variable validation or complex types
- Read [references/locals.md](references/locals.md) - Load when computing intermediate values or reducing duplication
- Read [references/root-module.md](references/root-module.md) - Load when organizing environment-specific configurations
- Read [references/remote-state.md](references/remote-state.md) - Load when configuring remote state, encryption, locking, or per-environment state keys
- Read [references/advanced-patterns.md](references/advanced-patterns.md) - Load when using data sources or dynamic blocks

Files in this skill

  • SKILL.md2.8 KB
  • eval-output.json2.9 KB
  • eval-trigger.json5.8 KB
  • moon.yml86 B
  • references/advanced-patterns.md444 B
  • references/locals.md848 B
  • references/module-definition.md844 B
  • references/module-structure.md862 B
  • references/remote-state.md832 B
  • references/root-module.md924 B
  • references/typed-variables.md599 B
  • sources.json1.2 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.