What problem does it solves?
This Skill provides a comprehensive guide to Terraform's native testing framework, enabling module authors to validate configuration updates and prevent breaking changes. It helps users write effective unit and integration tests, ensuring infrastructure reliability and reducing deployment risks.
Core Features & Use Cases
- Test File Creation: Guidance on creating
.tftest.hcl files with test, run, and assert blocks for various testing scenarios.
- Unit & Integration Testing: Differentiates between
plan mode (fast, no resources created) for unit tests and apply mode (real infrastructure validation) for integration tests.
- Mock Providers: Explains how to simulate provider behavior for isolated, cost-free unit tests, accelerating feedback loops (requires Terraform 1.7.0+).
- Use Case: Develop a robust test suite for a new AWS VPC module, including unit tests for variable validation and output correctness, and integration tests to verify actual VPC creation and subnet configuration.
Quick Start
Explain how to write a unit test for a Terraform module that validates the vpc_id output is not empty and starts with 'vpc-', using command = plan.