TA-002-P · Question #426
How does Terraform determine dependencies between resources?
The correct answer is A. Terraform automatically builds a resource graph based on resources, provisioners, special meta-. Terraform automatically constructs a dependency graph by inspecting references between resources in your configuration. When one resource references an attribute of another (e.g., aws_subnet.id used in an EC2 instance), Terraform infers that the subnet must be created first. It…
Question
How does Terraform determine dependencies between resources?
Options
- ATerraform automatically builds a resource graph based on resources, provisioners, special meta-
- BTerraform requires all dependencies between resources to be specified using the depends_on
- CTerraform requires resources in a configuration to be listed in the order they will be created to
- DTerraform requires resource dependencies to be defined as modules and sourced in order
How the community answered
(23 responses)- A91% (21)
- B4% (1)
- C4% (1)
Explanation
Terraform automatically constructs a dependency graph by inspecting references between resources in your configuration. When one resource references an attribute of another (e.g., aws_subnet.id used in an EC2 instance), Terraform infers that the subnet must be created first. It also accounts for provisioners and the special depends_on meta-argument for cases where implicit references don't exist. You do NOT need to list resources in order or define all dependencies manually - Terraform's graph engine handles this automatically, enabling parallel creation of independent resources.
Topics
Community Discussion
No community discussion yet for this question.