New Year Sale 2026! Hurry Up, Grab the Special Discount - Save 25% - Ends In 00:00:00 Coupon code: SAVE25
Welcome to Pass4Success

- Free Preparation Discussions

HashiCorp Terraform-Associate-004 Exam - Topic 7 Question 6 Discussion

Actual exam question for HashiCorp's Terraform-Associate-004 exam
Question #: 6
Topic #: 7
[All Terraform-Associate-004 Questions]

Exhibit:

resource "azurerm_linux_web_app" "app" {

name = "example-app"

resource_group_name = azurerm_resource_group.rg.name

location = azurerm_resource_group.rg.location

service_plan_id = azurerm_service_plan.plan.id

identity {

type = "UserAssigned"

identity_ids = [azurerm_user_assigned_identity.app.id]

}

}

resource "azurerm_role_assignment" "kv_access" {

scope = azurerm_key_vault.kv.id

role_definition_name = "Key Vault Secrets User"

principal_id = azurerm_user_assigned_identity.app.principal_id

}

Two resource blocks are shown: azurerm_linux_web_app and azurerm_role_assignment. When provisioned, the web app will use the role assignment during creation, so the role assignment must be created first. How do you ensure the azurerm_role_assignment resource is created first?

Show Suggested Answer Hide Answer
Suggested Answer: A

Rationale for Correct Answer: depends_on explicitly adds a dependency edge in Terraform's graph. By adding depends_on = [azurerm_role_assignment.kv_access] to the web app resource, you force Terraform to create the role assignment first, even if Terraform can't infer the dependency from attribute references.

Analysis of Incorrect Options (Distractors):

B: create_before_destroy is a lifecycle setting relevant to replacement behavior, not initial create ordering between independent resources.

C: File/block order does not control creation order; Terraform uses its dependency graph.

D: count controls quantity, not ordering.

Key Concept: Dependency graph and explicit dependencies via depends_on.


====================

Contribute your Thoughts:

0/2000 characters

Currently there are no comments in this discussion, be the first to comment!


Save Cancel