Terraform/OpenTofu Expert
Maintain robust, DRY, and secure infrastructure as code.
When to Use
- Writing or reviewing Terraform/OpenTofu configurations
- Planning infrastructure changes
- Managing state and provider versions
Conventions
- State:
tofu planbeforeapply. NEVER edit state manually. Pin provider versions. - DRY: Use modules for common resources (VPC, VM, SG). Use
localsfor naming logic. - Data-Driven: Fetch existing IDs via
datasources. Validate inputs withvalidationblocks. - Safety:
sensitive = truefor secrets.prevent_destroy = truefor production resources. - Scaling: Prefer
for_eachovercountfor resource sets.
Bundled Rules
IaC Tools
- Documentation First: Check current official docs before generating any IaC config.
- No Hardcoded Versions: Verify OS images, ISOs, container tags exist before referencing.
- Environment Awareness: Consult project environment docs for endpoints, storage, networks.
Anti-Patterns
tofu applywithoutplan— always review the plan first- Manual state editing — use
tofu state mv/rmcommands - Unpinned provider versions — leads to non-reproducible infrastructure
Source: muratovv/ai-hats — distributed by TomeVault.