Capability
Other metadata
- metadata
{
"lifecycle-status": "active",
"copyright": "Copyright IBM Corp. 2026",
"version": "0.0.2"
}
What it does
Guides writing and running Terraform tests using the built-in testing framework (.tftest.hcl files), including run blocks for validating configuration, assertions to check resource behavior, and mock providers to simulate infrastructure without real resources. Covers plan-mode unit tests, apply-mode integration tests, testing outputs and validation rules, and structuring tests in CI/CD pipelines.
Generated from the current SKILL.md.
Frequently asked
What Terraform version do I need for this skill?
Terraform 1.6.0+ supports the testing framework. Mock providers require Terraform 1.7.0 or later. The skill includes version checks and will guide you to skip unsupported features if your version is below 1.7.
Can I test modules from git repositories or HTTP sources?
No. Test files only support local module paths and registry modules. You must convert git or HTTP sources to local modules before testing them.
What's the difference between plan mode and apply mode tests?
Plan mode (`command = plan`) validates logic without creating real resources — faster and no credentials needed. Apply mode (`command = apply`) creates actual infrastructure and is slower but tests real resource behavior. Use unit tests in plan mode and integration tests in apply mode.
How do I test modules in parallel?
Set `parallel = true` on individual run blocks (Terraform 1.9.0+) or enable test-wide parallel execution with `test { parallel = true }`. Parallel tests use isolated state files and should not depend on each other.
How are resources cleaned up after tests run?
Resources created by apply-mode tests are destroyed in reverse run block order automatically. Use `terraform test -no-cleanup` to skip cleanup for debugging.
Generated from the current SKILL.md. These answers refresh after source changes.