terraform-test
- Repo stars 0
- Author updated Live
- Author repo skills-registry
- Domain
- DevOps
- Compatible agents
-
- Claude Code
- Cursor
- Cline
- Codex
- Windsurf
- Gemini CLI
- +20
- Trust score
- 88 / 100 · community maintained
- 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 special requirements
- Permissions
-
- Read-only
- Write / modify
- Shell exec
- Network behavior
- Local-only
- Install commands
- 26 variants
Profile is derived at build time from SKILL.md and install vectors. Subject to drift from author intent.
Heads up: 未限定 allowed-tools,默认拥有全部工具权限。
---
name: terraform-test
description: **WORKFLOW SKILL** — Write and run Terraform tests (.tftest.hcl). WHEN: "create terraform test"…
category: devops
runtime: no special runtime
---
# terraform-test output preview
## PART A: Task fit
- Use case: **WORKFLOW SKILL** — Write and run Terraform tests (.tftest.hcl). WHEN: "create terraform test", "write tftest", ".tftest.hcl", "mock provider", "test module", "test assertion". USE FOR: test files, run blocks, assertions, mock providers, plan-mode unit tests, apply-mode integration tests, test troubleshooting. DO NOT USE FOR: Bicep code, architecture decisions, deployment (use azure-deploy). Use when this capability is needed..
- Inputs: target material, constraints, expected output, and acceptance criteria.
- Evidence boundary: follow “Quick Reference / File Structure / Test File Components” and do not present inference as author intent.
## PART B: Execution result
- **01** The card summarizes the use case; runtime output centers on “**WORKFLOW SKILL** — Write and run Terraform tests (.tftest.hcl). WHEN: "create terraform test", "write tftest", ".tftest.hcl", "mock provider", "test module", "test assertion". USE FOR: test files, run blocks, assertions, mock providers, plan-mode unit tests, apply-mode integration tests, test troubleshooting. DO NOT USE FOR: Bicep code, architecture decisions, deployment (use azure-deploy). Use when this capability is needed.”.
- **02** When the source has headings, the agent prioritizes “Quick Reference / File Structure / Test File Components” so the result follows the author’s structure.
- **03** Typical output includes task judgment, concrete steps, required commands or file edits, validation, and follow-up options.
- **04** Risk context follows the fingerprint: read files, write/modify files, run shell commands; mostly runs locally; usually needs no extra API key.
## Running Rules
- read files, write/modify files, run shell commands; mostly runs locally; usually needs no extra API key.
- Validate with a small sample before expanding scope.
- Return the result, validation criteria, and next iteration options. The source does not require a stable slash command. After installation, invoke the skill by name and describe the task.
Name target files or source material, expected output, forbidden changes, and whether network or shell access is allowed. Permission fingerprint: read files, write/modify files, run shell commands.
Start with a small task and check whether the result follows “Quick Reference / File Structure / Test File Components”. Inspect diffs, logs, previews, or tests before expanding scope.
Confirm the final output includes a concrete result, evidence, and next action. If it stays generic, tighten inputs, boundaries, and acceptance criteria.
---
name: terraform-test
description: **WORKFLOW SKILL** — Write and run Terraform tests (.tftest.hcl). WHEN: "create terraform test"…
category: devops
source: tomevault-io/skills-registry
---
# terraform-test
## When to use
- **WORKFLOW SKILL** — Write and run Terraform tests (.tftest.hcl). WHEN: "create terraform test", "write tftest", ".tft…
- Use it when the task has clear inputs, repeatable steps, and validation criteria.
## What to provide
- Target material, scope, expected result, and forbidden changes.
- Whether network, commands, file writes, or external services are allowed.
## Execution rules
- Organize steps around “Quick Reference / File Structure / Test File Components” and keep inference separate from source facts.
- read files, write/modify files, run shell commands; mostly runs locally; usually needs no extra API key.
- Validate with a small sample before expanding the task.
## Output requirements
- Return the deliverable, key evidence, validation method, and next action.
- Mark missing information as unknown; do not invent commands, platforms, or dependencies. The author source anchors workflow facts; repository files anchor sources and commands; Fluxly only adds fit, limitations, and quality judgment.
skill "terraform-test" {
input -> user goal + target files + boundaries + acceptance criteria
context -> Quick Reference / File Structure / Test File Components
rules -> SKILL.md triggers / order / output contract
runtime -> no special runtime | read files, write/modify files, run shell commands | mostly runs locally
guardrails -> usually needs no extra API key + small-sample validation + diff/log review
output -> copyable result + checklist + next iteration
} Terraform Test Skill
Write, organize, and run Terraform's built-in test framework for Azure infrastructure modules.
Reference: Terraform Testing Documentation
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 |
| Apply mode | command = apply (default) — creates real infrastructure |
1.6 |
| Mock provider | Simulates provider without real API calls | 1.7 |
| Parallel execution | parallel = true on independent run blocks |
1.9 |
| Expect failures | Verify validation rules reject invalid input | 1.6 |
File Structure
my-module/
├── main.tf
├── variables.tf
├── outputs.tf
└── tests/
├── defaults_unit_test.tftest.hcl # Plan mode (fast)
├── validation_unit_test.tftest.hcl # Plan mode (fast)
└── full_stack_integration_test.tftest.hcl # Apply mode (creates resources)
Naming convention: *_unit_test.tftest.hcl (plan mode), *_integration_test.tftest.hcl (apply mode).
Test File Components
- 0–1
testblock (test-wide settings) - 1+
runblocks (test scenarios, sequential by default) - 0–1
variablesblock (file-level inputs, highest precedence) - 0+
providerblocks (provider configuration) - 0+
mock_providerblocks (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).
Key Syntax Rules
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 |
expect_failures |
list | — | Expected validation failures |
Assert Syntax
assert {
condition = <boolean expression>
error_message = "Human-readable failure description"
}
Assertions can reference: resource attributes, outputs, run.<name>.<output>, var.*, data sources.
Variables precedence: run-block > file-level > all other sources.
See references/test-examples.md for module blocks, plan options, and prior run references.
Mock Providers (TF 1.7+)
Simulate Azure provider without API calls — ideal for unit tests.
Use mock_provider "azurerm" with mock_resource and mock_data blocks.
When to use: Unit tests, CI without Azure credentials, fast local development.
When NOT to use: Integration tests, validating actual Azure API behavior.
See references/mock-providers.md for full mock patterns and examples.
Common Test Patterns
See references/test-examples.md for: conditional resources, tag validation,
resource count with for_each, variables precedence, and prior run references.
Steps
terraform test # All tests
terraform test tests/defaults.tftest.hcl # Specific file
terraform test -verbose # Detailed output
terraform test -filter=test_resource_group # Filter by name
terraform test -no-cleanup # Debug: keep resources
Rules
- Naming:
*_unit_test.tftest.hcl/*_integration_test.tftest.hcl - Plan mode first: Use
command = planfor fast, cost-free validation - Clear error messages: Describe what went wrong and expected state
- Test isolation: Independent run blocks where possible
- Variable coverage: Test multiple combinations for all code paths
- Mock for speed: Use mock providers in CI without Azure access
- Negative testing: Use
expect_failuresfor validation rule coverage - Sequential only when needed: Only chain run blocks via
run.<name>when required
Terraform MCP Integration
Use mcp_terraform_search_providers to validate that resource types used in
test assertions exist in the target provider version.
Reference Index
| File | Contents |
|---|---|
references/test-examples.md |
Canonical example, common patterns, variables, module blocks |
references/test-patterns.md |
Unit vs integration patterns, CI/CD examples, complex assertions |
references/mock-providers.md |
Mock provider setup, mock resources/data sources, override files |
references/test-execution.md |
CLI commands, parallel execution, verbose/debug, diagnostics |
Source: aivandelindt/azure-agentic-infraops — distributed by TomeVault.
Decide Fit First
Design Intent
How To Use It
Boundaries And Review