terraform-test

Automate Terraform configuration testing with plan, apply, and mock provider modes.

4|1|Updated Oct 26, 2025
One-click install
npx skills add https://github.com/hashi-demo-lab/claude-skill-hcp-terraform --skill terraform-test-hashi-demo-lab
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: terraform-test
Source: https://github.com/hashi-demo-lab/claude-skill-hcp-terraform/tree/main/terraform-test
Command: npx skills add https://github.com/hashi-demo-lab/claude-skill-hcp-terraform --skill terraform-test-hashi-demo-lab

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Terraform configurations often drift and break when changes are made. This Skill provides a structured approach to write and run tests, ensuring reliability and safety across infrastructure code.

Core Features & Use Cases

  • Unit testing with plan mode to validate logic without creating resources.
  • Integration testing with apply mode to verify real infrastructure behavior.
  • Mocks and data sources to simulate provider behavior and enable fast feedback in CI.

Quick Start

  • Create tests under the tests/ directory using run blocks, variables, and asserts.
  • Run tests locally with: terraform test
  • Explore results and iterate on configurations to improve coverage.

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?

Terraform unit tests validate configuration logic using plan mode without provisioning resources. You define test blocks with run, variables, and assertions under a tests directory to verify expected resource attributes and behavior locally.

Can I use mock providers in Terraform tests for CI pipelines?

Yes, mock providers simulate infrastructure behavior to enable fast, deterministic feedback in CI. By mocking data sources and provider responses, you execute tests without real cloud dependencies or external API rate limits.

What is the difference between plan mode and apply mode in Terraform testing?

Plan mode executes unit tests by validating logic against the planned state without creating resources. Apply mode runs integration tests by provisioning real infrastructure to verify actual cloud behavior before destroying resources.

How do I run integration tests for Terraform modules?

Integration testing uses apply mode to provision real infrastructure and verify module behavior. You define run blocks with variables and module configurations, then execute locally using the terraform test command to iterate on coverage.

Does Terraform test support parallel execution controls?

Yes, Terraform test supports parallel execution controls alongside state_key and plan_options configurations. These controls manage test block concurrency, helping optimize run times for complex module and provider configurations.

Why do my Terraform configurations drift and break during changes?

Infrastructure configurations drift when untracked changes occur in cloud environments. Structured testing using run blocks, assertions, and mock providers ensures reliability and safety by validating logic before applying changes.