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.65k forks source link

Trying to update the value for the `identity.type` argument for the `azurerm_container_group` resource throws error #27999

Open hknutsen opened 1 day ago

hknutsen commented 1 day ago

Is there an existing issue for this?

Community Note

Terraform Version

1.9.8

AzureRM Provider Version

4.9.0

Affected Resource(s)/Data Source(s)

azurerm_container_group

Terraform Configuration Files

provider "azurerm" {
  features {}
}

resource "azurerm_resource_group" "example" {
  name     = "example-rg"
  location = "northeurope"
}

resource "azurerm_log_analytics_workspace" "example" {
  name                = "example-log"
  resource_group_name = azurerm_resource_group.example.name
  location            = azurerm_resource_group.example.location
}

resource "azurerm_container_group" "example" {
  name                = "example-ci"
  resource_group_name = azurerm_resource_group.example.name
  location            = azurerm_resource_group.example.location
  os_type             = "Linux"

  container {
    name   = "hello-world"
    image  = "mcr.microsoft.com/azuredocs/aci-helloworld:latest"
    cpu    = 1
    memory = 1

    ports {
      port     = 443
      protocol = "TCP"
    }
  }

  diagnostics {
    log_analytics {
      workspace_id  = azurerm_log_analytics_workspace.example.workspace_id
      workspace_key = azurerm_log_analytics_workspace.example.primary_shared_key
    }
  }

  # identity {
  #   type = "SystemAssigned"
  # }
}

Debug Output/Panic Output

╷
│ Error: updating Container Group (Subscription: "***"
│ Resource Group Name: "example-rg"
│ Container Group Name: "example-ci"): performing ContainerGroupsCreateOrUpdate: unexpected status 400 (400 Bad Request) with error: InvalidLogAnalytics: The log analytics setting is invalid. WorkspaceId and WorkspaceKey should not be null or empty.       
│
│   with azurerm_container_group.example,
│   on main.tf line 16, in resource "azurerm_container_group" "example":
│   16: resource "azurerm_container_group" "example" {
│
╵

Expected Behaviour

When uncommenting the identity block, Terraform should enable the system-assigned identity for the container group.

Actual Behaviour

When uncommenting the identity block, Terraform throws an error when trying to update the container group.

Steps to Reproduce

  1. terraform init
  2. terraform apply
  3. Uncomment the identity block
  4. terraform apply

Important Factoids

No response

References

No response

hadiulla commented 22 hours ago

i am able to reproduce the issue and here is my observation.