CICD-243 · Terraform module testing
Encyclopedia · Terraform and infrastructure as code · All snippets
Previous · CICD-242 · Next · CICD-244
1. Where it fits
- Placement CI run step.
- Prerequisites trusted Linux runner, Terraform CLI, reviewed IaC and a disposable state for writes.
- Platforms local-linux, github-actions, gitea-actions.
2. Copy the snippet
bash
terraform init -backend=false -input=false
terraform test -no-color3. How it works
Initialization prepares the working directory and installs locked providers. Backend flags decide whether state is contacted. Terraform evaluates the module's fixture runs and assertions. Provider choice determines whether resources are created.
4. Verify the result
Put module tests under tests/ and mock providers for offline invariants. Tests using real providers can create resources.
Validation syntax-validated (Bash parse). Status definitions.