terraform-skill

Guide Terraform and OpenTofu module design, testing, CI/CD, and security.

39|14|Updated Mar 23, 2026
One-click install
npx skills add https://github.com/aws-samples/sample-apex-skills --skill terraform-skill-aws-samples
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: terraform-skill
Source: https://github.com/aws-samples/sample-apex-skills/tree/main/skills/terraform-skill
Command: npx skills add https://github.com/aws-samples/sample-apex-skills --skill terraform-skill-aws-samples

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

Terraform and OpenTofu teams often struggle to ship reliable infrastructure changes without brittle module structures, missing tests, insecure defaults, and costly CI/CD mistakes; this Skill turns those best practices into actionable guidance.

Core Features & Use Cases

  • Module and code structure guidance: Choose the right module hierarchy (resource → module → infrastructure → composition) and keep environments separate from reusable modules.
  • Testing strategy for IaC: Select the right testing approach (native tests vs Terratest vs static analysis) and handle plan/apply differences, computed values, and set-type blocks.
  • CI/CD pipeline patterns: Implement practical validate/test/plan/apply stages with cost-aware testing and plan artifacts.
  • Security & compliance hardening: Use secure configuration patterns and integrate tools like Trivy and Checkov with guardrails against common misconfigurations.
  • Production-ready Terraform mechanics: Apply consistent naming, variable/output conventions, version pinning, and safe refactoring patterns (including moved blocks).

Quick Start

Activate terraform-skill and ask: "Review my Terraform/OpenTofu module plan and suggest improvements to structure, testing strategy, CI/CD stages, and security checks."

Frequently Asked Questions about terraform-skill

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I structure Terraform modules for production environments?

Terraform module structure should follow a resource to module to infrastructure to composition hierarchy, keeping environments separate from reusable modules. Consistent naming, variable and output conventions, and version pinning ensure safe refactoring and reliable infrastructure changes.

What is the best way to test infrastructure-as-code written in Terraform or OpenTofu?

Testing infrastructure-as-code involves selecting the right approach among native tests, Terratest, and static analysis. You must handle plan and apply differences, computed values, and set-type blocks to ensure reliable validation before deploying changes.

How do I implement CI/CD pipelines for Terraform with cost optimization?

Implement Terraform CI/CD pipelines by configuring validate, test, plan, and apply stages with cost-aware testing and plan artifacts. This approach optimizes CI/CD costs while maintaining safe plan and apply semantics during infrastructure deployments.

How do I integrate security scanning into Terraform infrastructure-as-code workflows?

Integrate security scanning into Terraform workflows using tools like Trivy and Checkov to establish guardrails against common misconfigurations. Apply secure configuration patterns to harden security and compliance across your infrastructure-as-code.

Does this infrastructure-as-code guidance work with OpenTofu?

Yes, this infrastructure-as-code guidance fully supports OpenTofu alongside Terraform. It provides expert direction for designing, testing, and securing OpenTofu infrastructure changes using reusable module patterns and production-ready workflows.