terraform-tests

Write Terraform tests using .tftest.hcl syntax with test and run blocks.

Updated Jan 20, 2026
One-click install
npx skills add https://github.com/Luscii/terraform-fluentbit-luscii-presets --skill terraform-tests
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: terraform-tests
Source: https://github.com/Luscii/terraform-fluentbit-luscii-presets/tree/main/.github/skills/terraform-tests
Command: npx skills add https://github.com/Luscii/terraform-fluentbit-luscii-presets --skill terraform-tests

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This skill enables Terraform practitioners to write comprehensive tests using Terraform's built-in testing framework, including test blocks, run blocks, assertions, and provider configuration, to validate modules before deployment.

Core Features & Use Cases

  • Supports end-to-end test structures with test, run, variables, provider, and module blocks to exercise Terraform modules.
  • Enables setup, validation, and cleanup via helper modules and assertions, including negative testing with expect_failures.
  • Ideal for validating module behavior, provider interactions, and configuration changes across environments before applying real changes.

Quick Start

Use this skill to create tests in a file like tests/integration.tftest.hcl and run terraform test tests/integration.tftest.hcl to verify your module.

Frequently Asked Questions about terraform-tests

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

FAQPage Schema
How do I write Terraform tests using .tftest.hcl files?

Terraform tests use .tftest.hcl files containing test blocks, run blocks, and assertions to validate module behavior. You organize test files to exercise local modules and remote providers, then run terraform test to verify configurations before deployment.

What is the best way to validate Terraform modules before deployment?

Validating Terraform modules before deployment is best done using the built-in testing framework with test, run, and assertion blocks. This approach exercises module behavior and provider interactions to ensure configuration changes are safe across environments.

Can I perform negative testing in Terraform with expect_failures?

Negative testing in Terraform is supported using the expect_failures mechanism within run blocks. You configure assertions to anticipate and verify intentional module failures, ensuring your infrastructure modules handle invalid configurations as expected.

How do I organize helper modules for Terraform test setup and validation?

Helper modules for Terraform test setup and validation are organized within test files to manage data generation and cleanup. You structure these alongside test and run blocks to provide necessary scaffolding and validate outputs across local and remote providers.

Does Terraform test support variable and provider scoping for module testing?

Terraform test supports variable and provider scoping within .tftest.hcl files to isolate module testing environments. You define provider configurations and variables directly in test blocks to control context and ensure accurate assertion results.