If you work with Azure resources and Terraform, sooner or later, you’ll face this.
You deploy a resource (say, a Managed Identity) using Terraform, and after a few days, you want to add something simple — maybe a Role Assignment.
But as soon as you run:
terraform plan
Boom — you see a terrifying message:
-/+ resource "azurerm_user_assigned_identity" "my_identity" {
id = "/subscriptions/xxxxxxx/resourceGroups/xyz/providers/Microsoft.ManagedIdentity/userAssignedIdentities/my_identity"
location = "eastus"
name = "my_identity"
~ principal_id = "11111111-1111-1111-1111-111111111111" => "22222222-2222-2222-2222-222222222222"
~ tenant_id = "aaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa" => "aaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa"
}
Plan: 1 to add, 0 to change, 1 to destroy.
You start thinking —
“Wait, what?? Why will it recreate my Managed Identity? I did nothing except plan to add a role assignment!”
Continue reading “Terraform ignore_changes : A Life Saver When Azure Resources Drift”