Skip to content
Sarj Code Standards

no-unused-module-outputs

Ban Terraform module outputs without a reachable consumer or exact external contract.

Why

Unused exports duplicate an infrastructure interface and obscure which resources own values. A file-local search cannot establish non-use: unchanged parents, other roots and nested value flows matter.

Fix

Trace parent and nested modules, root re-exports, remote state, scripts, CI and external users. Remove a proven-unused export while preserving its resource and safety dependencies. Preserve uncertain external users with an exact module/output/reason/evidence record in iac.no-unused-module-outputs.external_outputs. Do not fabricate consumers or visualization references.

Examples

Before — flagged Remove an unconsumed child export
.sarj-standards.toml
[iac.no-unused-module-outputs]
internal_modules = ["child"]
child/outputs.tf
output "unused" { value = true }
main.tf
module "child" { source = "./child" }
After — preferred Keep a child output consumed by a root contract
.sarj-standards.toml
[iac.no-unused-module-outputs]
internal_modules = ["child"]
child/outputs.tf
output "used" { value = true }
main.tf
module "child" { source = "./child" }
output "public" { value = module.child.used }