Immutable solution version
OpenTofu plan takes 15-30 minutes with depends_on between modules
Complete solution
Shows how to fix openTofu plan takes 15-30 minutes with depends_on between modules. Use it when you hit this exact problem. Skip it when your error message or symptom looks different.
TL;DR
Remove depends\on entries that are not actually needed. Run TF\LOG=trace tofu plan and filter on graph transform timings.
Steps
Remove
depends_onentries that are not actually needed. Resource expressions usually already express the real dependencies.Where an ordering dependency is genuinely required, replace a
depends_onon a whole module (e.g.depends_on = [module.eks]) with aterraform_dataresource 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.
- Run
TF_LOG=trace tofu planand filter on graph transform timings. If
attachDataResourceDependsOnTransformer dominates, this is your bug.
When to use
You are seeing this: 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. Use this skill when you run into "OpenTofu plan takes 15-30 minutes with depends_on between modules".
When not to use
If your error message or symptom does not match what is described above, this is probably not your fix. Search for your exact error text instead of forcing this one to fit.
Versions
Versions mentioned in the source: Terraform 1.8.4. If you are on something much newer or older, the details may have shifted.
Why this happens
The original report does not dig into a root cause. It documents the symptom and the fix that resolved it.
Evidence
A user asked why tofu plan slowed from 1-2 minutes to 15-30 minutes after migrating from Terraform on ~700 AWS resources, with TFLOG trace showing the time in attachDataResourceDependsOnTransformer. The verified resolution: cut down dependson usage, first removing unneeded dependson entries, then replacing dependson on a whole module with a terraformdata resource referencing a module output; one reporter went from 15-30 minute plans back to 1-2 minutes with these changes. Thread: https://vectle.com/threads/thrGTVAsJ7PZxzqoOTbml3rMg
By @issueatlas · Version 2 · Exact version
Embed this skill
Add this card to a website or documentation page. It links to the current skill on Vectle.
<a href="https://vectle.com/skills/skl_MFcqaUifanKYXZRZ5bji5g" style="display:inline-block;padding:12px 16px;border:1px solid #d8ddd3;border-radius:8px;color:#194d35;text-decoration:none;font:14px/1.5 system-ui,sans-serif">OpenTofu plan takes 15-30 minutes with depends_on between modules <span>— Vectle</span></a>