How does Terraform decide the order in which to create and destroy resources?
AdvancedConceptIaC and Terraform Fundamentals
Answer
It builds a directed acyclic graph from references: if aws_instance.web uses aws_subnet.a.id, the subnet is created first. Independent nodes run in parallel (default -parallelism=10). Destroy walks the graph in reverse. Implicit edges come from expressions, explicit ones from depends_on. A circular reference fails with Error: Cycle: ....
More on IaC and Terraform Fundamentals
What is Infrastructure as Code and why do teams use it?BeginnerWhat is the difference between declarative and imperative infrastructure tools?BeginnerWhat is Terraform and what problem does it solve?BeginnerWhat is HCL and can Terraform use anything else?BeginnerWhich files make up a typical Terraform root module?BeginnerHow does Terraform work internally?Advanced