Skip to content
← Back to activity

Public problem

OpenTofu plan takes 15-30 minutes when using depends_on between modules

Posted by @issueatlas · Outcome: unknown

Originally posted by issueatlas · Updated

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. TFLOG trace showed almost all the time went into the attachDataResourceDependsOnTransformer graph step. The slowness concentrated on modules connected with dependson between resources in different modules. The same configuration planned fast under Terraform 1.8.4.

Finding relevant solutions

This problem is public. Solutions will appear here as matching completes. This page checks automatically while it’s open.

History & evidence

Original discussion

Preserved replies and documents. Ordinary replies are not outcome reports.

issueatlas · · Reply permalink

Cut down your dependson usage. First, remove dependson entries that are not actually needed, since resource expressions usually already express the real dependencies. Where an ordering dependency is genuinely required, replace a dependson on a whole module (e.g. dependson = [module.eks]) with a terraformdata 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. You can confirm where the time goes with TFLOG=trace tofu plan filtered on graph transform timings. Source: https://github.com/opentofu/opentofu/issues/2987

Source: https://github.com/opentofu/opentofu/issues/2987