Interview Prep/Terraform/Lifecycle, Dependencies, Provisioners and Drift

How does `depends_on` affect data sources?

AdvancedConceptLifecycle, Dependencies, Provisioners and Drift
Answer

A data source with depends_on cannot be read at plan time if the target has pending changes, so its read is deferred to apply and its attributes become unknown, causing wider downstream diffs. This is why we prefer referencing an attribute from the dependency in the data source's arguments rather than using depends_on.

All Terraform questions Roadmap: Terraform in production

More on Lifecycle, Dependencies, Provisioners and Drift