Terraform Associate Exam QuestionsBrowse all questions from this exam

Terraform Associate Exam - Question 47


FILL BLANK -

You need to specify a dependency manually.

What resource meta-parameter can you use to make sure Terraform respects the dependency?

Type your answer in the field provided. The text field is not case-sensitive and all variations of the correct answer are accepted.

Show Answer
Correct Answer:

To manually specify a dependency in Terraform and ensure that resource creation adheres to the specified order, you should use the 'depends_on' meta-parameter. This meta-parameter explicitly informs Terraform of dependencies between resources, ensuring that all actions (like creates, updates, or destroys) on the dependent resources are executed only after the specified dependencies have been addressed.

Discussion

17 comments
Sign in to comment
habros
Nov 29, 2022

depends_on

Cololand
Nov 10, 2024

depends_on

Eltooth
Jan 6, 2023

"depends_on" is correct answer.

svsilence
Jan 10, 2023

depends_on

kopper2019
Feb 10, 2023

depends_on

[Removed]
Feb 25, 2023

depends_on

jutove_mi
Jul 5, 2024

what is the question??

G4Exams
Apr 30, 2023

explicit dependencies are set with "depends_on". No doubt.

joyboy23
Jan 6, 2024

depends_on, Not depend_on

vibzr2023
Sep 27, 2024

depends_on In Terraform, sometimes the order in which resources are created, updated, or destroyed is important because some resources might rely on others. For example, you might not want a virtual machine to be created before the network it relies on is set up. However, there are situations where Terraform cannot infer dependencies from the configuration alone, especially when the dependency is indirect or based on operational considerations outside of Terraform's knowledge. The depends_on meta-parameter is used for this purpose. You can add depends_on to any resource block to explicitly specify that the resource depends on other resources. Terraform will ensure that the resources listed in depends_on are created before the resource that defines the dependency.

vibzr2023
Sep 27, 2024

Suppose you have a scenario where you need to ensure a logging service is up and running before your main application starts, but there's no direct reference between the two in your Terraform configuration. You could use depends_on to define this relationship: resource "aws_cloudwatch_log_group" "example" { name = "example-log-group" # Other configuration... } resource "aws_instance" "app_server" { ami = "ami-123456" instance_type = "t2.micro" # Other configuration... # Manually specify dependency on the CloudWatch Log Group depends_on = [aws_cloudwatch_log_group.example] }

vibzr2023
Sep 27, 2024

In the above example, even though the aws_instance.app_server doesn't directly reference the aws_cloudwatch_log_group.example, we've used depends_on to tell Terraform that the app_server should only be created after the example-log-group CloudWatch Log Group is created. This ensures that your logging infrastructure is in place before your application starts running. depends_on is particularly useful in cases where Terraform cannot automatically determine the correct order for creating, updating, or destroying resources based on the configuration alone.

vibzr2023
Sep 27, 2024

In the above example, even though the aws_instance.app_server doesn't directly reference the aws_cloudwatch_log_group.example, we've used depends_on to tell Terraform that the app_server should only be created after the example-log-group CloudWatch Log Group is created. This ensures that your logging infrastructure is in place before your application starts running. depends_on is particularly useful in cases where Terraform cannot automatically determine the correct order for creating, updating, or destroying resources based on the configuration alone.

kennynelcon
Jul 16, 2023

depends_on

Bilalglg93350
Sep 18, 2023

depends_on

sjoe
Sep 26, 2023

depends_on

thor7
Sep 29, 2023

depends_on

Power123
Sep 30, 2023

depends_on

gspb
Oct 30, 2023

depends_on

KrishTeam
Mar 15, 2024

did anyone got this question in exam

filled
Apr 6, 2024

sure did glad to know I at least got this one correct

Bengi
Jun 23, 2024

https://developer.hashicorp.com/terraform/language/meta-arguments/depends_on The depends_on meta-argument instructs Terraform to complete all actions on the dependency object (including Read actions) before performing actions on the object declaring the dependency. When the dependency object is an entire module, depends_on affects the order in which Terraform processes all of the resources and data sources associated with that module.