nerdexam
HashiCorp

TA-002-P · Question #275

resource "aws_s3_bucket" "example" { bucket = "my-test-s3-terraform-bucket" ...} resource "aws_iam_role" "test_role" { name = "test_role" ...} Due to the way that the application code is written…

The correct answer is B. Add explicit dependency using depends_on . This will ensure the correct order of. Use the depends_on meta-argument to handle hidden resource dependencies that Terraform can't automatically infer. Explicitly specifying a dependency is only necessary when a resource relies on some other resource's behavior but doesn't access any of that resource's data in its…

Understand Terraform basics

Question

resource "aws_s3_bucket" "example" { bucket = "my-test-s3-terraform-bucket" ...} resource "aws_iam_role" "test_role" { name = "test_role" ...} Due to the way that the application code is written , the s3 bucket must be created before the test role is created , otherwise there will be a problem. How can you ensure that?

Options

  • AThis will already be taken care of by terraform native implicit dependency. Nothing else
  • BAdd explicit dependency using depends_on . This will ensure the correct order of
  • CCreate 2 separate terraform config scripts , and run them one by one , 1 for s3 bucket ,
  • DThis is not possible to control in terraform . Terraform will take care of it in a native way ,

How the community answered

(47 responses)
  • A
    2% (1)
  • B
    91% (43)
  • C
    4% (2)
  • D
    2% (1)

Explanation

Use the depends_on meta-argument to handle hidden resource dependencies that Terraform can't automatically infer. Explicitly specifying a dependency is only necessary when a resource relies on some other resource's behavior but doesn't access any of that resource's data in its arguments.

Topics

#Terraform dependencies#Explicit dependencies#depends_on#Resource ordering

Community Discussion

No community discussion yet for this question.

Full TA-002-P Practice