terraform-test

Comprehensive guide for writing and running Terraform tests. Use when creating test files (.tftest.hcl), writing test scenarios w…

hashicorp 752 ↓ 5.6k MPL-2.0 updated 1mo ago
Claude Code
View source ↗

What it does

  • references/MOCKPROVIDERS.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/CICD.md — GitHub Actions and GitLab CI pipeline examples
  • references/EXAMPLES.md — Complete example test suite (unit, integration, and mock tests for a VPC module)
  • Test file (.tftest.hcl / .tftest.json): Contains run blocks 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+)

Requirements & configuration

  • 3. Default to plan: Use command = plan unless you need to test real resource behavior

Derived from the skill's own SKILL.md documentation · extracted 2026-07-23

Comprehensive guide for writing and running Terraform tests. Use when creating test files (.tftest.hcl), writing test scenarios with run blocks, validating infrastructure behavior with assertions, mocking providers and data sources, testing module outputs and resource configurations, or troubleshooting Terraform test syntax and execution.

Source

Repository: https://github.com/hashicorp/agent-skills

terraform-test FAQ

What does the terraform-test skill do?

Comprehensive guide for writing and running Terraform tests. Use when creating test files (.tftest.hcl), writing test scenarios with run blocks, validating infrastructure behavior with assertions, mocking providers and data sources, testing module outputs and resource configurations, or troubleshooting Terraform test syntax and execution. references/MOCKPROVIDERS.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/CICD.md — GitHub Actions and GitLab CI pipeline examples

What does terraform-test require?

3. Default to plan: Use command = plan unless you need to test real resource behavior

How do I install terraform-test?

Run: npx -y skills add https://github.com/hashicorp/agent-skills --skill terraform-test --agent claude-code — the source lives at github.com/hashicorp/agent-skills.

Maintain terraform-test?

Let people know it's listed here — add the badge (live metrics, light/dark aware) or a plain link to your README or docs.

terraform-test on getagentictools
[![terraform-test on getagentictools](https://getagentictools.com/badge/skills/hashicorp-agent-skills-terraform-test.svg)](https://getagentictools.com/skills/hashicorp-agent-skills-terraform-test?ref=badge)
npx agentictools info skills/hashicorp-agent-skills-terraform-test

The second line is the CLI lookup for this page — handy in READMEs and docs.