Hi
I came across a very tricky situation and I hope you can help me on figuring this out.
I have some Azure VMs deployed using the same module, one per environment. Everything seems to be working fine for all, except “acceptance” VM. For this, out of sudden, Terraform Plan reports that the instance needs to be replaced, arguing that the location had been changed. The location was not changed at all though.
Some actions:
- I’ve double-checked the location in the state file, and it’s using the correct one.
- No changes on the parameters for this env that could cause the replacement.
Snippet from Plan output
# module.windows.azurerm_windows_virtual_machine.windows-vm["vm-app-01"] must be replaced
-/+ resource "azurerm_windows_virtual_machine" "windows-vm" {
~ admin_password = (sensitive value)
- availability_set_id = "" -> null
- dedicated_host_id = "" -> null
- encryption_at_host_enabled = false -> null
- eviction_policy = "" -> null
~ id = "/subscriptions/..." -> (known after apply)
- license_type = "" -> null
~ location = "westeurope" -> (known after apply) # forces replacement
name = "vm-app-01"
Snippet State file
"attributes": {
"id": "/subscriptions/...",
"location": "westeurope",
"name": "vm-app-01",
"tags": {
My point is… Why is TF trying to re-create the resources arguing location change only for this environment?
Any clues would be really appreciated.