Interview Prep/Terraform/Dependencies, Cycles and Providers

`depends_on` on a data source makes every plan show `(known after apply)` for things that never change.

AdvancedTroubleshootingDependencies, Cycles and Providers
Answer

Likely causes → A data source with depends_on (or inside a module with module-level depends_on) is deferred until apply whenever the dependency has any pending change. All values derived from it become unknown, causing noisy diffs and sometimes replacements.

Diagnose → In the plan, look for <= data "..." ... (depends on a resource or a module with changes pending) lines.

Fix → Remove depends_on and make the data source reference a specific attribute (for example vpc_id = aws_vpc.main.id) so the dependency is precise.

Prevent → Ban module-level depends_on in review unless documented.

All Terraform questions Roadmap: Terraform

More on Dependencies, Cycles and Providers