terraform_skill

This skill guides Terraform and OpenTofu projects from modules and testing to CI/CD, helping you choose patterns and ensure secure, reliable infrastructure.
  • Shell

2

GitHub Stars

1

Bundled Files

2 months ago

Catalog Refreshed

3 months ago

First Indexed

Readme & install

Copy the install command, review bundled files from the catalogue, and read any extended description pulled from the listing source.

Installation

Preview and clipboard use veilstrat where the catalogue uses aiagentskills.

npx veilstrat add skill adibfirman/dotfiles --skill terraform

  • SKILL.md16.5 KB

Overview

This skill provides practical, production-ready guidance for authoring, testing, and operating Terraform or OpenTofu infrastructure-as-code. It focuses on module design, testing strategies (native tests, Terratest), CI/CD patterns, state and dependency management, and security scanning. Use it to improve reliability, maintainability, and cost control for IaC projects.

How this skill works

The skill inspects common Terraform/OpenTofu workflows and recommends patterns for module hierarchy, file and block ordering, naming conventions, and version pinning. It helps choose and implement testing approaches, integrate static and security scanners (trivy, checkov), design CI/CD pipelines, and troubleshoot state or dependency issues. Advice is actionable and tied to Terraform features (native tests, mock providers) and real-world cost tradeoffs.

When to use it

  • Creating or refactoring Terraform/OpenTofu modules and environments
  • Choosing a testing approach: quick validation, native tests, or Terratest
  • Designing CI/CD pipelines for plan/review/apply with cost controls
  • Debugging state, dependency ordering, or resource recreation issues
  • Implementing security scanning and policy-as-code checks

Best practices

  • Separate reusable modules from environment configs; keep modules small and single-responsibility
  • Use descriptive resource names; use "this" only for true singletons
  • Order blocks consistently: count/for_each first, tags near end, lifecycle last
  • Prefer for_each for stable addressing; use count only for simple boolean or fixed counts
  • Run static analysis and security scans in PRs; run expensive integration tests only on main
  • Pin Terraform minor versions and provider major versions; lock module versions in prod

Example use cases

  • Create a networking module with examples/complete and examples/minimal for tests and docs
  • Add native terraform test files for input validation and use mock providers to avoid cloud costs
  • Set up CI stages: validate (fmt, validate, tflint), test (native/Terratest), plan, apply with approvals
  • Migrate count-based subnets to for_each to prevent cascading recreation when zones change
  • Integrate trivy and checkov in pre-commit or pipeline to catch misconfigurations early

FAQ

Use native tests for lightweight schema and plan/app validation (Terraform 1.6+), and mock providers for cost-free unit testing. Use Terratest for full integration tests that require real resources or when you need complex programmatic assertions.

How do I avoid deletion-order errors for VPC/subnet changes?

Use locals with try() to create stable references that hint dependency order, or add explicit depends_on sparingly. Locals help ensure subresources are deleted before parent CIDR associations.

Built by
VeilStrat
AI signals for GTM teams
© 2026 VeilStrat. All rights reserved.All systems operational
terraform skill by adibfirman/dotfiles | VeilStrat