What problem does it solve?
Terraform module authors often need to validate configuration updates without risking real infrastructure. This Skill provides a complete framework to author, run, and validate tests for Terraform modules using Terraform's built-in test framework.
Core Features & Use Cases
- Test File Essentials: Works with .tftest.hcl or .tftest.json files containing run blocks, variables, and assertions.
- Plan vs Apply: Supports unit tests in plan mode and integration tests in apply mode to balance speed and realism.
- Mock Providers & Module Testing: Enables testing with mock providers and testing both local and registry modules to ensure reliability across environments.
- CI/CD Readiness: Integrates into pipelines to catch regressions in Terraform configurations before deployment.
Quick Start
Create a tests/ directory with a file like tests/defaults_unit_test.tftest.hcl that demonstrates a simple plan-mode test. Then run terraform test to execute the suite. You can reference outputs from previous runs and use multiple modules to structure tests.