Use this Terraform module review checklist before merging or deploying infrastructure code. It helps reviewers validate the module’s input contract, provider constraints, state boundaries, dependency graph, lifecycle behavior, plan output, tests, and drift response without relying on memory or informal approval.
Overview
A Terraform module review is more than checking whether the configuration is formatted correctly. A module is an interface between application or platform teams and the infrastructure provider. Its variables, outputs, resource names, state boundaries, and provider requirements all become part of an operational contract.
The safest review separates concerns into stages. First, confirm that the module expresses the intended design. Next, verify that it can be initialized, validated, linted, and tested consistently. Finally, inspect a plan in the correct environment and decide how the team will respond if real infrastructure has drifted from configuration.
This checklist assumes the module is stored in version control and changes are reviewed through a pull request. It applies to local modules, shared modules, and modules consumed through a registry, although organization-specific policy and approval requirements may add further checks. For broader interface and state design guidance, see the Terraform Module Design Guide.
Fast review summary
- Contract: Are variables, defaults, validations, and outputs clear?
- Safety: Are state, secrets, replacements, and destructive changes controlled?
- Compatibility: Are Terraform and provider version constraints deliberate?
- Behavior: Does the dependency graph and lifecycle configuration match the design?
- Evidence: Do formatting, validation, linting, tests, plan, and policy checks pass?
- Operations: Is drift detectable, explainable, and recoverable?
Checklist by scenario
1. Reviewing a new module
- Confirm the module has a clear purpose and a documented supported use case.
- Check that the root module contains only the resources and child modules needed for that purpose.
- Review variable names for consistent conventions, useful descriptions, appropriate types, and sensible defaults.
- Require variable validation where invalid values could create an unsafe or confusing plan.
- Check whether optional behavior is represented clearly. Avoid several loosely related Boolean flags when a typed object or a small set of explicit modes would be easier to understand.
- Confirm outputs expose useful identifiers without leaking credentials, tokens, private keys, or other sensitive values.
- Check resource and data-source names for stable, descriptive naming. Names should help reviewers connect configuration to plan output.
- Verify that the README documents inputs, outputs, examples, prerequisites, provider assumptions, and known limitations.
2. Reviewing a provider or Terraform upgrade
- Inspect the
required_versionconstraint and confirm that it matches the versions used by CI and local development. - Review
required_providersentries, including provider source addresses and version constraints. - Prefer constraints that permit compatible updates while preventing untested major-version changes. The exact constraint should follow the team’s release and testing policy.
- Regenerate or review the dependency lock file according to repository practice. A lock file should be changed deliberately, not as an accidental side effect of initialization.
- Read the provider upgrade notes relevant to resources used by the module, especially changes to defaults, attributes, import behavior, and replacement rules.
- Run plans against representative environments and compare unexpected changes with the provider release’s intended behavior.
- Record any required state migrations, moved blocks, imports, or manual follow-up actions in the pull request and README.
3. Reviewing a state or architecture change
- Identify which resources belong in this module’s state and which belong to the caller or another module.
- Check that shared infrastructure is not accidentally recreated inside each module instance.
- Review changes to module addresses, resource names,
for_eachkeys, andcountindexes. These can cause Terraform to interpret an existing object as a destroy-and-create operation. - When an address is intentionally moved, require an explicit migration plan using the project’s approved state-move or import workflow.
- Confirm remote state access, locking, permissions, and environment separation are handled outside the module where appropriate.
- Check that sensitive values are not being passed through outputs, logs, plans stored in accessible locations, or unprotected artifacts.
4. Reviewing a change with lifecycle or dependency impact
- Inspect every use of
depends_on. Add explicit dependencies only when Terraform cannot infer the relationship from referenced values. - Review
create_before_destroy,prevent_destroy, andignore_changesas operational decisions, not harmless metadata. - Confirm that
ignore_changesis narrow and documented. Ignoring an attribute can hide configuration drift indefinitely. - Check replacement behavior for names, immutable fields, network attachments, identity bindings, and other provider-specific constraints.
- Make sure a lifecycle rule does not prevent a necessary security update or leave orphaned resources.
5. Reviewing a drift or incident fix
- Establish whether the difference was caused by manual change, an external controller, a provider behavior change, a failed apply, or an incorrect state record.
- Compare configuration, state, refresh results, and the real resource before choosing a corrective action.
- Do not use a broad refresh-and-apply cycle as a substitute for understanding the difference.
- Decide whether to reconcile the resource to code, update code to the intentional real-world state, import a resource, move state, or remove an obsolete object.
- Capture the cause and prevention step in the issue or pull request so the same drift is easier to diagnose later.
What to double-check
Inputs and outputs
Inputs should describe what callers are allowed to control. Avoid exposing provider-specific implementation details unless they are genuinely part of the module’s supported interface. Use precise types for collections and objects so invalid shapes fail early. Defaults should be safe and unsurprising; a default that creates a public endpoint, broad permission, or expensive resource deserves especially careful review.
Outputs should be stable and useful to callers. If an output contains sensitive data, mark it appropriately and consider whether it should exist at all. A sensitive flag helps reduce accidental display, but it does not make a secret safe to store in state or export to downstream systems.
State safety and secrets
Terraform state can contain values needed to manage resources, including values that are sensitive even when they are hidden in normal command output. Review the backend, access permissions, encryption, locking, retention, and artifact handling used by the execution environment. Never place credentials in variable defaults, committed variable files, examples, or command history.
Also check whether a data source or provider configuration retrieves a secret unnecessarily. Prefer references to an approved secret-management workflow and document the required permissions. A module review should identify who can read, change, and recover the state, not only who can merge the code.
Provider constraints and dependency graphs
Provider constraints communicate compatibility, but they do not replace testing. Check the source address, constraint range, lock-file change, and CI matrix together. A module that works only with one unrecorded local provider version is not reproducible.
For dependencies, follow references through locals, data sources, child modules, and resource attributes. Terraform can infer many relationships, and inferred dependencies are usually easier to maintain than broad explicit dependencies. A dependency review should ask whether ordering is correct, whether a cycle is possible, and whether a small change will unnecessarily replace unrelated resources.
Plan evidence and tests
Run terraform fmt -check, terraform init with the repository’s normal upgrade policy, and terraform validate in a clean environment. Add linting and security or policy checks used by the team. Examples may include rules that reject unencrypted storage, unrestricted network access, missing ownership metadata, or disallowed regions; the specific rules should come from the organization’s policy set.
Use unit-style tests, native Terraform tests, integration tests, or a combination suited to the module’s risk. Test valid inputs, invalid inputs, optional paths, resource counts, important outputs, and replacement-sensitive changes. A plan should be generated with the same variable files, backend assumptions, credentials, and provider versions used by the target pipeline. Review the plan for unexpected creates, updates, destroys, replacements, permission changes, and changes outside the intended scope.
Pull-request review table
| Area | Reviewer question | Evidence to request |
|---|---|---|
| Interface | Can a caller understand and safely use every input? | Variable definitions, validations, examples |
| State | Will resource addresses and ownership remain stable? | State impact summary and migration steps |
| Versions | Are Terraform and provider versions reproducible? | Constraints, lock-file diff, CI result |
| Security | Could this expose a secret or broaden access? | Policy results and permission review |
| Behavior | Does the plan match the intended change? | Saved or linked plan review, test output |
| Operations | How will drift, failure, and rollback be handled? | Runbook, alert, import, or recovery procedure |
Common mistakes
- Reviewing only the diff: A small configuration change can produce a large replacement or permission change. Always inspect the plan.
- Using broad version ranges without testing: A permissive constraint can admit behavior changes that the module has not verified.
- Treating sensitive as encrypted: Sensitivity controls display in some Terraform workflows; it does not remove the value from state.
- Adding
ignore_changesto silence noise: This can turn a visible configuration problem into permanent, unnoticed drift. - Using
depends_oneverywhere: Overly broad dependencies make plans slower and can create unnecessary ordering or replacement behavior. - Changing keys casually: Renaming a
for_eachkey or changing a resource address may destroy and recreate an existing object unless migration is handled explicitly. - Testing only the happy path: Invalid inputs, empty collections, disabled features, and upgrade paths often expose the most expensive defects.
- Applying from a laptop without matching CI: Different credentials, backends, provider locks, and variable files can produce different plans.
- Leaving the README behind: A module without current examples and migration notes shifts operational knowledge into private conversations.
When to revisit
Reuse this checklist before every module merge that changes resources, inputs, outputs, provider constraints, lifecycle rules, state addresses, or permissions. Revisit it during seasonal planning cycles when teams review cloud architecture, budgets, ownership, and recovery procedures. It is also valuable after a provider upgrade, Terraform version change, repository restructuring, security review, incident, or unexplained drift event.
Step-by-step pre-apply workflow
- Format: Run the repository’s formatting check and review unrelated formatting changes separately.
- Initialize: Initialize with the intended backend and provider-lock policy; do not casually upgrade dependencies during an unrelated change.
- Validate: Run configuration validation with the same module inputs and required providers used by CI.
- Lint and scan: Run linting, secret detection, security checks, and organization policy checks.
- Test: Execute focused module tests, then integration tests where the change affects real provider behavior.
- Plan: Generate a plan for the target workspace or environment with reviewed variables and credentials.
- Review: Check creates, updates, destroys, replacements, sensitive values, access changes, and out-of-scope resources.
- Approve and apply: Apply only through the approved execution path, then record the result and any follow-up migration.
- Verify: Confirm outputs, service health, monitoring, ownership metadata, and state consistency after the apply.
- Document: Update the README or runbook when the interface, upgrade path, operational behavior, or recovery process has changed.
Keep a copy of this checklist with the pull-request template or module repository. The exact commands and policy tools may change, but the review questions remain useful: what does the module promise, what can it change, where is that change recorded, and how will the team detect and recover when reality no longer matches code?