The unexpected Azure resource replacement
Investigate why a Terraform plan wants to replace an existing Azure resource group, and resolve the unexpected change without applying it.

The scenario
A configuration change makes Terraform propose destroying and recreating a real, empty lab resource group. Find the cause in the plan and restore a no-change plan without applying the replacement.
Mission objectives
- Inspect the plan and identify the replacement and its cause.
- Correct the lab configuration without replacing the resource group.
- Verify the original group and remove the isolated lab resources.
Lab README
Unexpected Azure resource replacement
This lab creates one uniquely named, empty Azure resource group with Terraform. A separate configuration input then makes a subsequent plan propose replacing that group. Investigate the plan and restore a no-change plan without applying the replacement. Terraform state and plans can contain sensitive data; keep them private. Never use this exercise against an existing resource.
An empty resource group normally has no direct usage charge, but Azure pricing and policies vary. Use an isolated subscription with known safe guardrails and remove lab resources promptly. Do not add any resources to the group: teardown refuses to delete a nonempty group.
Install Azure CLI, Terraform 1.5+, Python 3 and Bash on Linux. Log in and select
the intended subscription. Microsoft.Resources must already be registered.
Use a private local Linux filesystem for Terraform state.
export AZURE_SUBSCRIPTION_ID="your-subscription-id"
./setup.sh "$AZURE_SUBSCRIPTION_ID" northeurope --accept-costs
terraform -chdir=.lab-state plan -input=false
Do not apply the replacement plan. Inspect the plan and configuration
inputs in .lab-state, then restore a no-change plan without replacing the
group. Run ./verify.sh and ./teardown.sh; teardown checks the group's
identity, ownership marker, contents and destroy plan. It retains private state
afterward. Confirm the group is absent before removing .lab-state.
Get the lab
Download and inspect the installer before running it. It checks the archive's SHA-256 digest and refuses to overwrite an existing lab directory.
curl -fsSLO https://devops.download/labs/cloudops-03-azure-terraform-replacement.sh less cloudops-03-azure-terraform-replacement.sh
bash cloudops-03-azure-terraform-replacement.sh
cd labs/cloudops-03-azure-terraform-replacement
./setup.sh "$AZURE_SUBSCRIPTION_ID" northeurope --accept-costsWhen you've made your changes, run ./verify.sh. Remove lab resources with ./teardown.sh.
Need a nudge?
Hint #1
Inspect the Terraform plan and identify which argument requires replacement.
Hint #2
Compare the values in .lab-state/terraform.tfvars.json and .lab-state/incident.auto.tfvars.json, including their precedence.
Hint #3 · Deep Dive Runbook on opsbreakfix.com
Solved it?
Read the Official Root Cause Analysis & Certification Roadmap on opsbreakfix.com
Continue to opsbreakfix.com ↗