Interview Prep/Terraform/Modules and Code Structure

Someone proposes `depends_on = [module.network]` on every other module "to be safe". Your take?

BeginnerScenarioModules and Code Structure
Answer

Situation read → Over-constraining the graph.

What I'd do →

  1. Remove blanket depends_on.
  2. Pass real outputs (module.network.vpc_id) so dependencies are implicit and precise.
  3. Keep explicit depends_on only for hidden dependencies, with a comment explaining why.

Why → Module-level depends_on makes every resource wait for every network resource, reduces parallelism and makes data sources inside defer to apply time.

Interview tip → Use references for ordering; use depends_on as a documented exception.

All Terraform questions Roadmap: Terraform

More on Modules and Code Structure