
Terraform Test
hashicorp/agent-skillsOfficial
Guide for writing Terraform tests: .tftest.hcl files, run blocks, assertions, mocks, and module output checks.
- CCM score
- 74 of 100
- skills.sh installs
- 9.5K
- GitHub stars
- 941
- last updated
- Aug 21, 2026
Own this skill? Claim it
What it does
- Covers plan and apply test modes, run block syntax, assert and expect_failures usage, sequential run dependencies, and state key sharing
- Includes reference files for mock providers (Terraform 1.7.0+), GitHub Actions and GitLab CI pipelines, and a full VPC module example suite
- Enforces a split between
*_unit_test.tftest.hclplan-mode files and*_integration_test.tftest.hclapply-mode files so CI can filter them separately - Designed for module authors writing Terraform tests who need the
.tftest.hclsyntax and patterns for output, resource, and data source checks
Install
$ npx -y skills add hashicorp/agent-skills --skill terraform-test -yInstalls into .agents/skills for every agent it finds here, and .claude/skills for Claude Code.
Files
Terraform Test
Terraform's built-in testing framework validates that configuration updates don't introduce breaking changes. Tests run against temporary resources, protecting existing infrastructure and state files.
Reference Files
references/MOCK_PROVIDERS.md— Mock provider syntax, common defaults, when to use mocks (Terraform 1.7.0+ only — skip if the user's version is below 1.7)references/CI_CD.md— GitHub Actions and GitLab CI pipeline examplesreferences/EXAMPLES.md— Complete example test suite (unit, integration, and mock tests for a VPC module)
Read the relevant reference file when the user asks about mocking, CI/CD integration, or wants a full example.
Core Concepts
- Test file (
.tftest.hcl/.tftest.json): Containsrunblocks that validate your configuration - Run block: A single test scenario with optional variables, providers, and assertions
- Assert block: Conditions that must be true for the test to pass
- Mock provider: Simulates provider behavior without real infrastructure (Terraform 1.7.0+)
- Test modes:
apply(default, creates real resources) orplan(validates logic only)
File Structure
Details
- Repository
- github.com/hashicorp/agent-skills
- Categories
- Testing & QA, DevOps & Cloud
More from hashicorp/agent-skills
All 16- Refactor Module6.9K
- Terraform Stacks5.9K
- Terraform Search Import5.2K
- Provider Resources4.3K
- New Terraform Provider4.1K
- Provider Actions4.1K
- Run Acceptance Tests3.9K
- Azure Verified Modules3.5K
- Provider Test Patterns3.5K
- Provider Docs3.4K
- Aws Ami Builder3.4K
- Push To Registry3.2K
- Azure Image Builder2.9K
- Windows Builder2.9K
- Terraform Style Guide13.8K
Similar to Terraform Test
More Testing & QA
provider-test-patternshashicorp/agent-skills3.5K installsTest structure, check functions, and scenario patterns for Terraform provider acceptance tests built on terraform-plugin-testing and the Plugin Framework.
terraform-style-guidehashicorp/agent-skills13.8K installsStyle guide that generates and reviews Terraform HCL following HashiCorp's official conventions and best practices.
terraform-module-librarysickn33/agentic-awesome-skills223 installsProduction-ready Terraform module patterns for AWS, Azure, and GCP with a Terratest-based testing approach.
terraform-skillsickn33/agentic-awesome-skills245 installsTerraform and OpenTofu guidance for testing, module design, CI/CD, and production infrastructure patterns.
terraform-infrastructuremanutej/luxor-claude-marketplace440 installsComprehensive Terraform guide covering providers, modules, state, and multi-cloud infrastructure-as-code patterns.
temporal-python-testingwshobson/agents11.6K installsStructured testing guide for Temporal Python workflows covering unit, integration, replay, and local setup.