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.51k stars 4.6k forks source link

Change in partition count for Standard SKU eventhub doesn't trigger destroy/create, fails on apply #15754

Open cailyoung opened 2 years ago

cailyoung commented 2 years ago

Community Note

Terraform (and AzureRM Provider) Version

terraform 1.0.9 azurerm 2.98.0 (with beta3 resource opt-in)

Affected Resource(s)

Terraform Configuration Files

resource "azurerm_eventhub_namespace" "namespace" {
  name                     = "${var.name}-eventhubnamespace"
  resource_group_name      = azurerm_resource_group.resource_group.name
  location                 = var.location
  sku                      = var.azure_monitor_eventhub_namespace_sku
  capacity                 = 1
  auto_inflate_enabled     = true
  maximum_throughput_units = 20

  network_rulesets {
    trusted_service_access_enabled = true
    default_action                 = "Allow"
  }
}

resource "azurerm_eventhub" "eventhub" {
  name                = "insights-metrics-pt1m" # hardcoded in the function.json
  resource_group_name = azurerm_resource_group.resource_group.name
  namespace_name      = azurerm_eventhub_namespace.namespace.name
  partition_count     = var.azure_monitor_eventhub_partition_count
  message_retention   = var.azure_monitor_eventhub_message_retention
}

the var.azure_monitor_eventhub_partition_count was 4 in state, and we want to change it to 32. SKU is Standard which supports 32 partitions.

Debug Output

Panic Output

Expected Behaviour

Plan should indicate destroy/create is required as Standard SKU doesn't allow partition resize after creation.

Actual Behaviour

Plan indicated update-in-place, apply failed, with:

│ Error: `partition_count` cannot be changed unless the namespace sku is `Premium`
│ 
│   with module.azure_monitor_azurediag_metrics.azurerm_eventhub.eventhub,
│   on sumologic_azure_metric_pipeline/main.tf line 21, in resource "azurerm_eventhub" "eventhub":
│   21: resource "azurerm_eventhub" "eventhub" {

Steps to Reproduce

  1. terraform apply with partition count < 32.
  2. Change variable to 32.
  3. terraform apply

Important Factoids

References

msterin commented 3 months ago

the current behavior is inconsistent with other places where Terraform does destroy/create where property cannot be updated in-place. It is also totally break the usage as it works fine for Premium SKU but just fails for Standard. It is not clear what do you expects users to do in this situation - manually destroy -target EventHub and then run apply ?

Also, the current behavior looks like a regression - before #13557 the current use case seems to have been working via destoy/recreate