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.61k stars 4.65k forks source link

application_insights_api_key - Infinite loop while checking for existing api keys #28050

Open TwinbrotherPro opened 1 day ago

TwinbrotherPro commented 1 day ago

Is there an existing issue for this?

Community Note

Terraform Version

v1.9.6

AzureRM Provider Version

4.9.0

Affected Resource(s)/Data Source(s)

application_insights_api_key

Terraform Configuration Files

resource "azurerm_resource_group" "example" {
  name     = "tf-test"
  location = "West Europe"
}

resource "azurerm_application_insights" "example" {
  name                = "tf-test-appinsights"
  location            = azurerm_resource_group.example.location
  resource_group_name = azurerm_resource_group.example.name
  application_type    = "web"
}

resource "azurerm_application_insights_api_key" "read_telemetry" {
  name                    = "tf-test-appinsights-read-telemetry-api-key"
  application_insights_id = azurerm_application_insights.example.id
  read_permissions        = ["aggregate", "api", "draft", "extendqueries", "search"]
}

Debug Output/Panic Output

azurerm_application_insights_api_key.example: Still creating... [20s elapsed]
azurerm_application_insights_api_key.example: Still creating... [30s elapsed]
azurerm_application_insights_api_key.example: Still creating... [40s elapsed]
azurerm_application_insights_api_key.example: Still creating... [50s elapsed]
azurerm_application_insights_api_key.example: Still creating... [1m0s elapsed]
azurerm_application_insights_api_key.example: Still creating... [1m10s elapsed]
azurerm_application_insights_api_key.example: Still creating... [1m20s elapsed]
azurerm_application_insights_api_key.example: Still creating... [1m30s elapsed]
azurerm_application_insights_api_key.example: Still creating... [1m40s elapsed]
azurerm_application_insights_api_key.example: Still creating... [1m50s elapsed]
azurerm_application_insights_api_key.example: Still creating... [2m0s elapsed]
azurerm_application_insights_api_key.example: Still creating... [2m10s elapsed]
azurerm_application_insights_api_key.example: Still creating... [2m20s elapsed]

Expected Behaviour

If the appinsights resourceazurerm_application_insights.example already has an api-key configured which is not meant to be managed by the current terraform state the resource azurerm_application_insights_api_key.read_telemetry should just ignore that existing key and manage the key described in the tf resource without issues.

Actual Behaviour

If there is already a key present which is not meant to be managed by the current terraform state the resource provider azurerm_application_insights_api_key ends up in an infinite loop unable to exit until the terraform timeout of that resource is reached. It is not possible to add another key as long the unmanaged one is existing.

Steps to Reproduce

Important Factoids

no

References

I already created a PR for a potential fix: https://github.com/hashicorp/terraform-provider-azurerm/pull/28037