"tags": this field cannot be set

Hi All,

I am trying to set a filter in Data Source using “tags” and I am getting error.

Could you kindly help me is there a way to add a filter/tag here?

data “azurerm_shared_image_version” “myimage” {
name = “1.0.1”
image_name = “windows”
gallery_name = “widows_galleries”
resource_group_name = “windows-images”
tags = {
name = “DEV”
}
}

Error: “tags”: this field cannot be set

on main.tf line 20, in data “azurerm_shared_image_version” “myimage”:
20: data “azurerm_shared_image_version” “myimage” {

  1. name should also be in quotes, I believe. And 2) does it work without the tags map?

The name can be without quotes, yeah it works without the tags

Can you get a debug log of a run?

Hi @nicethomaslearngit!

According to the documentation for this data source, only name, image_name, gallery_name, and resource_group_name are settable as query constraints.

The tags attribute is just an exported result attribute. You can refer to it in expressions elsewhere (data.azurerm_shared_image_version.myimage.tags), but you can’t query by it.

I’m not familiar with this data source in particular, but I suspect the azurerm provider here is just reflecting limitations of the underlying API. If Azure itself doesn’t allow looking up images by their tags, then unfortunately Terraform can’t support it either. I was going to suggest that you might open a feature request issue in the Azure provider if the underlying API does support tags, but it looks like you already did that! :slight_smile: