terraform test

DevOps Community

Skill notes

Quick Reference

Concept · Description · Min Version Test file · .tftest.hcl in tests/ directory · 1.6 Run block · Single test scenario with assertions · 1.6 Assert block · Condition that must be true for test to pass · 1.6 Plan mode · command = plan — validates logic, no resources created · 1.6

File Structure

Naming convention: *_unit_test.tftest.hcl (plan mode), *_integration_test.tftest.hcl (apply mode).

Test File Components

0–1 test block (test-wide settings) 1+ run blocks (test scenarios, sequential by default) 0–1 variables block (file-level inputs, highest precedence) 0+ provider blocks (provider configuration) 0+ mock_provider blocks (simulated providers, TF 1.7+)

Canonical Example

See references/test-examples.md for a complete Azure Resource Group test (unit tests, tag validation, expect_failures).

Run Block Attributes

Attribute · Type · Default · Description command · plan/apply · apply · Test mode variables · block · — · Override file-level variables module · block · — · Test alternate module (local/registry only) assert · block (1+) · — · Validation conditions

Fluxly profile Runtime and permissions are inferred by Fluxly static checks, not author declarations or runtime test results.
Domain
DevOps
Author-declared agents
No explicit declaration found; this is not inferred or tested compatibility
Static check
88 / 100 · heuristic scan, not runtime safety proof
Runtime evidence
Not run; no isolated runtime test evidence is currently recorded
Author / version / license
@tomevault-io · no license declared
Token usage
Lean
Setup complexity
Guided setup
External API key
Not required
Operating systems
Unspecified (assume cross-platform)
Runtime requirements
No explicit requirements detected
Detected file/system behavior
  • Read-only
  • Write / modify
  • Shell exec
Network behavior
Local-only
Install commands
None (reference only)

Heads up: Tool permissions are not declared; actual access depends on the runtime.

Output preview terraform-test.preview
# Canonical Example

See `references/test-examples.md` for a complete Azure Resource Group test (unit tests, tag validation, expect_failures).

Discussion

Powered by GitHub Discussions. Sign in with GitHub to comment, react, or subscribe.