terraform-testing

Automate Terraform module validation with .tftest.hcl test and run blocks.

Updated Jan 20, 2026
One-click install
npx skills add https://github.com/poc-micro-frontends/terraform-infrastructure --skill terraform-testing-poc-micro-frontends
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: terraform-testing
Source: https://github.com/poc-micro-frontends/terraform-infrastructure/tree/main/skills/terraform-testing
Command: npx skills add https://github.com/poc-micro-frontends/terraform-infrastructure --skill terraform-testing-poc-micro-frontends

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Terraform's built-in testing framework enables module authors to validate that configuration updates don't introduce breaking changes. Tests execute against temporary resources, protecting existing infrastructure and state files.

Core Features & Use Cases

  • Test File Components and Run blocks surface robust validation for Terraform modules, enabling unit tests (plan mode) and integration tests (apply mode), with support for mocking providers and data sources.
  • Module testing (local and registry) and provider mocking enable safe validation without creating real resources.
  • State management, parallel execution, and variable passing provide robust regression coverage across complex configurations.

Quick Start

Create a tests/ directory with a .tftest.hcl file defining test and run blocks, then run terraform test to validate your Terraform configuration.

Frequently Asked Questions about terraform-testing

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

FAQPage Schema
How do I validate Terraform modules without creating real cloud resources?

You can validate Terraform modules without real resources by using the testing framework's plan mode and mock_provider blocks to simulate AWS, Azure, and GCP resources, ensuring safe regression testing without modifying existing infrastructure.

What is the best way to structure Terraform test files for unit and integration testing?

Terraform testing uses .tftest.hcl or .tftest.json files containing test and run blocks. Place them in a tests directory to execute unit tests in plan mode and integration tests in apply mode with state management and parallel execution.

Can I mock providers and data sources in Terraform testing?

Yes, Terraform's testing framework supports mocking providers and data sources. Using mock_provider blocks within your .tftest.hcl files allows you to isolate module validation and run cross-resource assertions without authenticating to cloud platforms.

How do I run cross-resource assertions across multiple cloud providers in Terraform?

Cross-resource assertions are handled using assert blocks within run blocks in your test files. This framework validates configurations across AWS, Azure, and GCP patterns while supporting variable passing and state isolation during parallel execution.

Does the Terraform testing framework support parallel execution and state isolation?

Yes, the Terraform testing framework supports parallel execution with state isolation. This allows multiple run blocks to execute independently against temporary resources, protecting existing state files while providing robust regression coverage.