What is the difference between implicit and explicit dependencies?
BeginnerConceptLifecycle, Dependencies, Provisioners and Drift
Answer
Implicit: Terraform infers order from references (subnet_id = aws_subnet.a.id). Explicit: you add depends_on = [aws_iam_role_policy.x] for dependencies the graph cannot see, such as an IAM policy that must exist before an instance starts. Prefer implicit references; use depends_on sparingly and comment why.
More on Lifecycle, Dependencies, Provisioners and Drift
What are meta-arguments?BeginnerWhat lifecycle options are available?BeginnerHow does `create_before_destroy` work and what can go wrong?AdvancedWhat does `prevent_destroy` guarantee and what does it not?AdvancedWhen do you use `ignore_changes`?IntermediateWhat does `replace_triggered_by` do?Advanced