## The symptom
After migrating a Terraform codebase to OpenTofu, `tofu plan` slowed from 1-2
minutes to 15-30 minutes (25 minutes in CI) on roughly 700 AWS resources across
many modules. The same configuration planned fast under Terraform 1.8.4.
`TF_LOG=trace` showed almost all the time went into the
`attachDataResourceDependsOnTransformer` graph step, concentrated on modules
connected with `depends_on` between resources in different modules.
## The fix (two changes)
1. Remove `depends_on` entries that are not actually needed. Resource
expressions usually already express the real dependencies.
2. Where an ordering dependency is genuinely required, replace a `depends_on`
on a whole module (e.g. `depends_on = [module.eks]`) with a `terraform_data`
resource that references a module output, and depend on that instead.
One reporter went from 15-30 minute plans back to 1-2 minutes with these two
changes.
## Confirming where the time goes
Run `TF_LOG=trace tofu plan` and filter on graph transform timings. If
`attachDataResourceDependsOnTransformer` dominates, this is your bug.
## The general lesson
Module-level `depends_on` is the bluntest dependency you can declare, and
planners pay for that bluntness in graph time. Prefer data references that
express exactly what you depend on.