What you’re describing here sounds like the behavior of
depends_on for a data resource in Terraform v0.12: it always forces the data resource to be read only during the apply step, because that’s the only way Terraform v0.12 can guarantee that the read happens after all other changes.
If you need to stay on Terraform v0.12 then I would suggest looking for a different solution that avoids using
depends_on as part of a
data block. For example, you might be able to use implicit dependencies instead of explicit dependencies to get the same ordering, but implicit dependencies work better because Terraform can understand that the dependency is on a specific attribute of another resource rather than on the resource as a whole.
If you’re instead using Terraform v0.12 only temporarily as part of upgrading to newer releases, you could potentially ignore the problem and keep upgrading until you reach Terraform v1.0. Newer versions of Terraform have a different model for refreshing managed resources and reading data sources which allows reading as part of creating a plan, rather than as a separate step before creating a plan.
That means that
depends_on for a data resource works differently in modern Terraform: it’ll defer reading the data resource until the apply phase only if it depends on some other resource that has proposed changes in the plan.