Halloween Special 2026! Get Up to 25% OFF Practice Questions! Limited Time - Ends In 00:00:00 Coupon code: SAVE25
Welcome to Pass4Success

- Free Preparation Discussions

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

Posted by Kerrie on Mar 03, 2026 at 05:54 AM

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?

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.


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

Get Premium Terraform-Associate-004 Questions as Interactive Web-Based Practice Test or PDF Real Exam Format Detailed Explanations Instant Access Get Your Practice Test
26 comments · newest first
JE
Jesusa 2 months ago
D seems unnecessary. Count arguments don't really address the order issue.
JE
Jenise 2 months ago
C could work too, but it feels less explicit than A.
JO
Johana 2 months ago
I agree, A makes sense. It ensures the correct order of creation.
CO
Cornell 2 months ago
I think A is the best choice. The depends_on argument is clear and effective.
JO
Josefa 2 months ago
I feel like A is straightforward. Keeps things organized.
ON
Onita 3 months ago
Option C seems tempting, but it might confuse the order.
RO
Rodrigo 3 months ago
I agree, A makes sense. Dependencies are crucial in Terraform.
ER
Eric 3 months ago
I think option A is the best choice. It clearly defines the dependency.
GA
Galen 3 months ago
D seems unnecessary. Count arguments complicate things.
FA
Fabiola 3 months ago
C could work too, but it feels less explicit.
RO
Ronny 3 months ago
I agree, A makes sense. It ensures the right order.
ED
Edgar 4 months ago
I think A is the best choice. The depends_on argument is clear.
PR
Providencia 4 months ago
Count arguments? That's a bit overkill for this situation.
TA
Tanesha 4 months ago
B) is unnecessary, just stick with A).
SH
Sherell 5 months ago
Surprised that people think you can just rearrange the blocks!
LE
Leatha 6 months ago
I disagree, changing the order won't guarantee it.
LO
Loreen 6 months ago
A) is the way to go, definitely needs that depends_on!
CA
Caprice 6 months ago
D) is just overcomplicating things, stick to A).
JU
Julene 6 months ago
Surprised this isn't more straightforward, why not just use depends_on?
MA
Madalyn 6 months ago
B) doesn't really make sense here, right?
LE
Leonida 7 months ago
I think C) is a bit risky, order can be tricky.
CO
Corrie 7 months ago
A) is the way to go, definitely needs depends_on.
AN
Andra 7 months ago
I don't recall using count for this kind of dependency issue. Seems like it wouldn't help with the order of creation.
KA
Kayleigh 7 months ago
I feel like the create_before_destroy option is more about resource replacement than creation order. Not sure if it applies here.
SO
Soledad 7 months ago
I'm not entirely sure, but I remember something about resource dependencies. Could changing the order of the blocks work?
RE
Rene 7 months ago
I think we might need to use the depends_on argument to control the creation order. That sounds familiar from our Terraform practice.
0/2000 characters

Save Cancel