hashicorp / terraform-provider-azurerm

Terraform provider for Azure Resource Manager
https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs
Mozilla Public License 2.0
4.6k stars 4.64k forks source link

Data source azurerm_network_service_tags does not work properly for AzureFrontDoor #12046

Open tesharp opened 3 years ago

tesharp commented 3 years ago

Community Note

Terraform (and AzureRM Provider) Version

Terraform v0.15.4
on windows_amd64
+ provider registry.terraform.io/hashicorp/azurerm v2.60.0

Affected Resource(s)

Terraform Configuration Files

data "azurerm_network_service_tags" "frontdoor" {
  location        = azurerm_resource_group.main.location
  service         = "AzureFrontDoor.Backend"
  location_filter = " "
}

Debug Output

Panic Output

Expected Behaviour

Getting all IP's for AzureFrontDoor.Backend

Actual Behaviour

Getting error:

Error: specified service tag AzureFrontDoor.Backend not found globally

isServiceTagOf function in https://github.com/terraform-providers/terraform-provider-azurerm/blob/1aaa389743ff39c281367a8ad85b7b94540b4206/azurerm/internal/services/network/network_service_tags_data_source.go#L107 that match service tag to returned value from Azure makes the assumtion that name does not contain any dot, and if it does the last part is region. So for AzureFrontDoor.Backend it is unable to match the name to service.

Steps to Reproduce

  1. terraform apply

Important Factoids

References

wbreza commented 3 years ago

@tesharp - I ran into this same issue today and agree there is a bug. I did however find a workaround for my use case.

data "azurerm_network_service_tags" "service_tags" {
  location        = var.region
  service         = "AzureFrontDoor"
}

Omitting the Backend from the full service names appears to match on the first returned list of the AzureFrontDoor service names which happens to be Backend right now.

jamesw4 commented 1 year ago

Any update on this? Ran in to this exact issue today.