terraform-test

Validate Terraform configurations with plan-mode tests using .tftest.hcl files.

5|Updated Apr 29, 2023
One-click install
npx skills add https://github.com/n4vysh/dotfiles --skill terraform-test-n4vysh
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: terraform-test
Source: https://github.com/n4vysh/dotfiles/tree/main/home/dot_agents/skills/terraform-test
Command: npx skills add https://github.com/n4vysh/dotfiles --skill terraform-test-n4vysh

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

Terraform configurations are easy to write but hard to validate safely; this skill provides a structured approach to test infrastructure code using plan and apply workflows, mocks, and assertions to prevent breaking changes.

Core Features & Use Cases

  • Unit and integration tests for Terraform configurations using .tftest.hcl files.
  • Mock provider support to run tests without real cloud credentials and with predictable results.
  • Guided workflows for organizing tests, test file naming, and CI integration.

Quick Start

Create your first unit test under tests/ using *_unit_test.tftest.hcl and run terraform test to execute plan-mode validations.

Frequently Asked Questions about terraform-test

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I test Terraform configurations without using real cloud credentials?

To test Terraform configurations without real cloud credentials, use mock providers within .tftest.hcl files. Mock providers simulate infrastructure resources, allowing you to execute predictable plan and apply workflows safely during unit and integration testing.

What is the best way to structure Terraform unit and integration tests?

The best way to structure Terraform tests is using .tftest.hcl files organized under a tests/ directory. Apply naming conventions like *_unit_test.tftest.hcl for unit tests and *_integration_test.tftest.hcl for integration tests to ensure reproducible validation workflows.

How do I run Terraform tests in a CI pipeline to prevent breaking changes?

To run Terraform tests in a CI pipeline, execute terraform test against your structured .tftest.hcl files. This automates plan-mode validations and assertions for infrastructure code, ensuring safe, reproducible changes across module versions and CI integrations.

Does terraform test support mock providers for module validation?

Yes, terraform test supports mock providers for module validation. By configuring mocks within .tftest.hcl files, module authors can validate configurations and run assertions without provisioning real infrastructure or requiring actual cloud provider credentials.