Terraform Associate Exam QuestionsBrowse all questions from this exam

Terraform Associate Exam - Question 227


How does Terraform manage most dependencies between resources?

Show Answer
Correct Answer: D

Terraform automatically manages most resource dependencies by analyzing the relationships between resources based on their input and output variables. It detects references to other resources within resource blocks and creates implicit dependencies to ensure that resources are created, updated, or destroyed in the correct order. Explicit dependencies using the depends_on parameter are only required in specific scenarios where Terraform cannot automatically determine the dependency.

Discussion

9 comments
Sign in to comment
tbhtpOption: D
Oct 1, 2023

D. Terraform will automatically manage most resource dependencies. Terraform is designed to recognize and manage dependencies between resources automatically, based on the values of their attributes. When a resource references another resource's attributes, Terraform understands the dependency and will create, update, or destroy resources in the correct order to satisfy those dependencies. However, in some cases where explicit dependency management is needed, you can use the "depends_on" parameter to define additional dependencies.

BaburTurkOption: D
Feb 28, 2024

D. Terraform will automatically manage most resource dependencies. Option A is incorrect because Terraform does not use modules to manage dependencies. Option B is incorrect because the order that resources appear in Terraform configuration does not indicate dependencies. Option C is incorrect because the depends_on parameter is used to explicitly declare dependencies, not to automatically manage them.

Ashwin1011
Jan 27, 2024

Option D is incorrect because Terraform does not automatically manage all resource dependencies. Some resource dependencies are not visible to Terraform, and you need to explicitly specify them using the depends_on parameter. For example, the following Terraform configuration defines an EC2 instance and an IAM role. The EC2 instance depends on the IAM role, but this dependency is not visible to Terraform. You need to explicitly specify the dependency using the depends_on parameter. resource "aws_instance" "web" { depends_on = ["aws_iam_role.role"] } resource "aws_iam_role" "role" { } If you do not specify the depends_on parameter, Terraform will try to create the EC2 instance before the IAM role. This will fail because the EC2 instance needs the IAM role to be able to access AWS resources. In general, it is a good practice to explicitly specify dependencies using the depends_on parameter. This will help to ensure that your infrastructure is created and updated in the correct order.

Witwicky
Sep 29, 2023

D for me

campsOption: D
Oct 1, 2023

D. Terraform will automatically manage most resource dependencies Terraform is designed to automatically manage most resource dependencies by analyzing the relationships between resources based on their input and output variables. When Terraform detects that a resource relies on another resource's output or attribute, it creates an implicit dependency and ensures that resources are created, updated, or destroyed in the correct order.

oskarqOption: D
Oct 25, 2023

Only D

Freshtimi
Oct 26, 2023

D is correct

RajmaneOption: C
Feb 10, 2024

It's C depends on

[Removed]
Jul 15, 2024

https://developer.hashicorp.com/terraform/language/resources/behavior#resource-dependencies Most resource dependencies are handled automatically. Terraform analyses any expressions within a resource block to find references to other objects, and treats those references as implicit ordering requirements when creating, updating, or destroying resources. Since most resources with behavioral dependencies on other resources also refer to those resources' data, it's usually not necessary to manually specify dependencies between resources.