Confusion about desired state vs actual state in terraform

I have the following code in my Terraform file. Using this, I created a resource group in Azure. After the resource group was created, I manually added tags to it from the Azure portal. Based on my knowledge, when I run terraform plan, I should see no changes to the infrastructure as tags are not defined in my desired state in configuration file. However, in my case, Terraform is detecting a change and showing that the tags will be updated to null. Why is this happening, since I don’t have any tags defined in my desired state within the Terraform file?

resource “azurerm_resource_group” “example” {
name = “example”
location = “West Europe”
}

Hi @rahulnemade42,

The confusion I think is that your resource block describes the entire desired state, not just part of it, so it also declares that there should be no tags on the resource. If you add tags out of band, that then disagrees with your config, hence Terraform shows that they will be reverted.

If you don’t want to manage the tags attribute in your configuration, you can add that to the ignore_changes meta argument to avoid any subsequent updates to them.