terraform-test

Write and run Terraform tests using .tftest.hcl files.

5|Updated Feb 26, 2026
One-click install
npx skills add https://github.com/lidge-jun/cli-jaw-skills --skill terraform-test-lidge-jun
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: terraform-test
Source: https://github.com/lidge-jun/cli-jaw-skills/tree/main/terraform/code-generation/skills/terraform-test
Command: npx skills add https://github.com/lidge-jun/cli-jaw-skills --skill terraform-test-lidge-jun

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

This Skill provides a comprehensive guide to writing and executing tests for your Terraform configurations, ensuring infrastructure stability and preventing breaking changes.

Core Features & Use Cases

  • Test Framework: Learn to use Terraform's built-in testing capabilities with .tftest.hcl files.
  • Test Scenarios: Define tests using run blocks for apply or plan modes.
  • Assertions & Mocks: Validate infrastructure behavior with assertions and simulate provider responses using mock providers.
  • Use Case: You've updated a Terraform module and want to ensure it still deploys correctly and meets all requirements without manual verification. Use this Skill to write and run tests that cover various scenarios, from default configurations to edge cases.

Quick Start

Use the terraform-test skill to learn how to write a basic unit test for a Terraform module.

Frequently Asked Questions about terraform-test

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

FAQPage Schema
How do I write tests for Terraform modules using .tftest.hcl files?

Terraform testing uses .tftest.hcl files to validate module outputs and resource configurations. You define run blocks to execute plan or apply modes, then use assertions to verify expected infrastructure behavior without deploying real resources.

What are mock providers in Terraform testing and when should I use them?

Mock providers simulate provider responses during Terraform testing, allowing you to validate conditional logic and module configurations without real infrastructure dependencies. Use them to test edge cases and default configurations safely in isolated environments.

Can I validate Terraform HCL configurations without deploying real infrastructure?

Yes, Terraform testing validates HCL configurations using plan mode within run blocks. This executes tests against the planned state rather than applied resources, ensuring infrastructure stability and preventing breaking changes without provisioning actual cloud resources.

How do run blocks work when testing infrastructure as code with Terraform?

Run blocks in Terraform testing execute specific operations like plan or apply within .tftest.hcl files. They allow you to define distinct test scenarios that validate module behavior across various configurations, capturing state changes for subsequent assertions.

Do I need prior HCL syntax knowledge to use Terraform testing frameworks?

Yes, understanding Terraform HCL syntax and infrastructure as code principles is required. The testing framework builds upon these foundations, using HCL to structure .tftest.hcl files, define run blocks, and write assertions for module validation.

What is the best way to prevent breaking changes in Terraform modules?

Writing comprehensive Terraform tests using .tftest.hcl files prevents breaking changes by validating module outputs and resource configurations. Define assertions covering default setups and edge cases to ensure infrastructure stability across module updates without manual verification.