Terraform Test
Independent PiSkill directory guide. The original skill remains hosted by HashiCorp Agent Skills.
What is Terraform Test?
Guides Terraform's built-in testing framework with .tftest.hcl files, run blocks, assertions, mock providers, CI workflows, and safe validation of infrastructure behavior.
What does Terraform Test do?
Terraform Test is a HashiCorp Agent Skill for using Terraform's built-in testing framework with `.tftest.hcl` files. It covers run blocks, assertions, plan-versus-apply behavior, mock providers and CI patterns so infrastructure logic can be validated without relying only on manual plan review.
Who is Terraform Test best for?
- Terraform module authors
- Infrastructure teams adding regression tests
- Developers validating modules in CI
- Projects using mock providers for safer unit-style testing
Common use cases
- Write assertions for a Terraform module
- Test planned values without applying infrastructure
- Use mock providers for controlled test scenarios
- Add Terraform tests to a CI pipeline
How does Terraform Test work?
The skill defines test files containing one or more run blocks, chooses plan or apply behavior for each scenario, passes test variables and providers, and uses assertions to verify expected configuration. Where supported, mock providers can simulate provider behavior so logic is tested without creating real infrastructure.
Key benefits
- Adds repeatable regression testing to Terraform
- Supports both plan-level and apply-style scenarios
- Can reduce unnecessary cloud resource creation with mocks
- Integrates infrastructure testing into CI workflows
Things to know
- Apply-mode tests can create real resources and incur cost
- Mock providers cannot reproduce every cloud behavior
- Terraform and provider versions affect which test features are available
Compatible tools
Frequently asked questions
What is a .tftest.hcl file?
Can Terraform tests run without creating real resources?
Related skills
Terraform Stacks
Helps structure and orchestrate Terraform deployments across multiple environments or regions using Terraform Stacks and reusable infrastructure components.
Terraform Style Guide
Generates and reviews Terraform HCL using HashiCorp's official style conventions, recommended file organization, variables, outputs, providers, and maintainable infrastructure patterns.
Azure Validation
Validates Azure application and infrastructure readiness before deployment by checking configuration, permissions, dependencies, templates, and expected operational behavior.
New Terraform Provider
Scaffolds a new Terraform provider using the Terraform Plugin Framework, including Go module setup, provider server entrypoint, schema, configuration, build, and tests.
Terraform Search and Import
Discovers existing cloud resources with Terraform Search and brings unmanaged infrastructure under Terraform using bulk import and generated configuration workflows.
Azure Diagnostics
Investigates Azure application and infrastructure failures using resource state, logs, metrics, configuration, and dependency evidence, then recommends scoped remediation.