Your goal
Predict each proposed action before apply and explain why Terraform orders dependent resources.
Exercise 10 ยท 50 minutes
Read Terraform's dependency graph, distinguish update from replacement, apply only a reviewed saved plan, and prepare a destruction plan without executing it.
Before you start
Predict each proposed action before apply and explain why Terraform orders dependent resources.
Participant task
Format, validate, and confirm Terraform reports no changes. Stop if the baseline differs from Azure.
terraform fmt -check
terraform validate
terraform planAdd a terraform_data resource whose input uses the managed identity's principal ID and name. Predict the dependency edge this reference creates.
Generate the graph, locate the dependency, then save a plan. Explain why Terraform can determine creation order without depends_on.
terraform graph
terraform plan -out main.tfplanChange a tag and identify the in-place update. Separately create a speculative plan with -replace for the identity. Do not apply the replacement plan; explain its downstream effect and delete that plan file.
terraform plan -replace=<identity-resource-address>Apply only the reviewed normal plan. Then save a destruction plan and review its order without applying it.
terraform apply main.tfplan
terraform plan -destroy -out destroy.tfplan
terraform show destroy.tfplanExpected outcome
Add a precondition that rejects a missing required tag, then observe whether the failure occurs during validation or planning.
Finish
Delete local binary plan files, commit the configuration, and keep the sandbox for the module refactor.