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.58k stars 4.62k forks source link

azurerm_api_management stores subnet id as a lowercase string? meaning it prompts for modification even when there is none to be done #18399

Closed nmiddleton closed 1 year ago

nmiddleton commented 2 years ago

Is there an existing issue for this?

Community Note

Terraform Version

1.1.2

AzureRM Provider Version

3.21.1

Affected Resource(s)/Data Source(s)

azurerm_api_management

Terraform Configuration Files

resource "azurerm_resource_group" "example" {
  name     = "example-RESOURCES"
  location = "West Europe"
}
resource "azurerm_virtual_network" "example" {
  name                = "EXAMPLE"
  resource_group_name = azurerm_resource_group.example.name
  location            = azurerm_resource_group.example.location
  address_space       = ["10.0.1.0/27"]
}
resource "azurerm_subnet" "example" {
  name                 = "EXAMPLE"
  resource_group_name  = azurerm_resource_group.example.name
  virtual_network_name = azurerm_virtual_network.example.name
  address_prefixes     = ["10.170.1.0/28"]
  service_endpoints    = ["Microsoft.Web"]
}
resource "azurerm_api_management" "example" {
  name                = "example-apim"
  location            = azurerm_resource_group.example.location
  resource_group_name = azurerm_resource_group.example.name
  publisher_name      = "My Company"
  publisher_email     = "company@terraform.io"

  sku_name = "Developer_1"
  virtual_network_type = "Internal"
  virtual_network_configuration {
    subnet_id = azurerm_subnet.example.id
  }
}

Debug Output/Panic Output

# azurerm_api_management.example[0] will be updated in-place
  ~ resource "azurerm_api_management" "product-apim-service" {
        id                            = "/subscriptions/*********/resourceGroups/example-RESOURCES/providers/Microsoft.ApiManagement/service/example-apim"
        name                          = "example-apim"
           # (21 unchanged attributes hidden)

      ~ virtual_network_configuration {
          ~ subnet_id = "/subscriptions/*********/resourcegroups/example-resources/providers/microsoft.network/virtualnetworks/example/subnets/EXAMPLE" -> "/subscriptions/*********/resourceGroups/example-RESOURCES/providers/Microsoft.Network/virtualNetworks/EXAMPLE/subnets/EXAMPLE"
        }

   # (8 unchanged blocks hidden)
    }

Plan: 0 to add, 1 to change, 0 to destroy.

Do you want to perform these actions?
  Terraform will perform the actions described above.
  Only 'yes' will be accepted to approve.

  Enter a value: yes

azurerm_api_management.example[0]: Modifying... [id=/subscriptions//*********/resourceGroups/example-RESOURCES/providers/Microsoft.ApiManagement/service/example-APIM]
...

Expected Behaviour

its the same ID for subnet in the state as it is for the id of the subnet in the plan. so should not prompt for modification every time we run plan or apply.

Actual Behaviour

every time apply is executed, prompted for modification to the subnet id of the apim. Possibly because of case sensitivity. It seems the state stores much of the resource id as lowercase

~ subnet_id = 
"/subscriptions/---------/resourcegroups/**example-resources**/providers/microsoft.network/virtualnetworks/**example**/subnets/EXAMPLE" 
"/subscriptions/---------/resourceGroups/**example-RESOURCES**/providers/Microsoft.Network/virtualNetworks/**EXAMPLE**/subnets/EXAMPLE"
Whereas my resources contain some uppercase chars.

Steps to Reproduce

No response

Important Factoids

No response

References

No response

github-actions[bot] commented 1 year ago

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues. If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.