terraform-test

Automate Terraform testing with .tftest.hcl and .tftest.json files.

Updated Jan 16, 2026
One-click install
npx skills add https://github.com/kumewata/dotfiles --skill terraform-test-kumewata
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: terraform-test
Source: https://github.com/kumewata/dotfiles/tree/main/config/agents/skills/terraform-test
Command: npx skills add https://github.com/kumewata/dotfiles --skill terraform-test-kumewata

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Terraform configurations frequently require testing to guard against regressions when changes are made. This skill provides a structured framework to write and run tests that validate Terraform code safely and efficiently.

Core Features & Use Cases

  • Unit tests (plan mode) to validate logic without creating real resources.
  • Integration tests (apply mode) to verify end-to-end infrastructure behavior.
  • Mock providers to speed up feedback and remove credentials dependencies.
  • Support for local and registry modules and provider configurations to simulate realistic scenarios.

Quick Start

Create tests using .tftest.hcl files, define run and assert blocks, and run terraform test to validate configurations.

Frequently Asked Questions about terraform-test

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

FAQPage Schema
How do I write unit tests for Terraform configurations without creating real resources?

Terraform unit tests use plan mode to validate configuration logic without provisioning infrastructure. You write .tftest.hcl files containing run and assert blocks to evaluate plan outputs safely.

What is the best way to validate Terraform module outputs during testing?

Validating Terraform module outputs is handled by defining run blocks in .tftest.hcl or .tftest.json files. These blocks execute the module and evaluate the exported outputs against your expected assertions.

Can I use mock providers in Terraform tests to avoid needing cloud credentials?

Mock providers remove credentials dependencies and speed up feedback during Terraform testing. You define mock_provider blocks within your test files to simulate provider responses for local and registry modules.

How do I run integration tests for Terraform to verify end-to-end infrastructure behavior?

Terraform integration tests use apply mode to verify end-to-end infrastructure behavior by provisioning real resources. You execute them via the terraform test command using configured .tftest.hcl files.

Does Terraform testing support passing variables and plan_options in test runs?

Terraform testing supports passing variables and plan_options directly within run blocks in your test files. This allows you to simulate realistic scenarios and control execution behavior for both unit and integration tests.

Why should I use the terraform test command for infrastructure as code validation?

Using the terraform test command guards your infrastructure as code against regressions when changes are made. It provides a structured framework to automate validations across unit and integration test scenarios.