provider "azurerm" {
subscription_id = var.general.subscription_id
features {}
ignore_tags {
# Exact tag keys to ignore
keys = ["environment", "asset-category-id"]
}
}
And now I get this error:
╷
│ Error: Unsupported block type
│
│ on providers.tf line 26, in provider "azurerm":
│ 26: ignore_tags {
│
│ Blocks of type "ignore_tags" are not expected here.
Assistant
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.
The ignore_tags block isn't a valid configuration option for the AzureRM provider. The error is occurring because this block type doesn't exist in the provider's schema.
If you're trying to ignore certain tags to prevent Terraform from managing them, you have a few options:
Use lifecycle ignore_changes in individual resources:
Use the default_tags configuration (available in newer versions):
hcl
provider "azurerm" {
subscription_id = var.general.subscription_id
features {}
# This adds default tags to all resources
default_tags {
tags = {
managed_by = "terraform"
}
}
}
If you want to prevent Terraform from removing externally-applied tags, you'll need to handle this at the resource level using lifecycle rules, as there's no provider-level configuration for ignoring specific tags.
The correct provider configuration should look like:
hcl
provider "azurerm" {
subscription_id = var.general.subscription_id
features {}
}
What specific behavior are you trying to achieve with those tags? This will help me suggest the best approach for your use case.
User
can I add ignore_changes lifecycle to the provider definition, or only to each resource?
Assistant
You can only add lifecycle blocks with ignore_changes to individual resources, not to the provider definition. The lifecycle block is a resource-level configuration, not a provider-level one.
So this won't work:
hcl
provider "azurerm" {
subscription_id = var.general.subscription_id
features {}
# This is NOT valid
lifecycle {
ignore_changes = [tags]
}
}
If you have many resources and want to standardize this behavior, you could consider:
Creating modules that include the lifecycle rules
Using dynamic blocks or locals to define common tag sets
Writing a script to add these lifecycle blocks to your existing resources
Unfortunately, there's no global way to tell Terraform to ignore specific tags across all resources in a provider.
User
Why do you say that ignore_tags is supported in azurerm when it's not?
Assistant
I didn't say that ignore_tags is supported in azurerm - in fact, I said the opposite. In my first response, I clearly stated:
"The ignore_tags block isn't a valid configuration option for the AzureRM provider. The error is occurring because this block type doesn't exist in the provider's schema."
I was explaining that ignore_tags is not supported, which is why you're getting the error. Perhaps there was some confusion in how I worded my response?
To be completely clear: ignore_tags is not and has never been a valid configuration option for the AzureRM provider. The error message you received confirms this - Terraform is telling you that blocks of type "ignore_tags" are not expected in the provider configuration.