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

AzureRM provider always destroys and recreates Topics in Premium service bus namespace #23597

Open chintavasisht opened 1 year ago

chintavasisht commented 1 year ago

Is there an existing issue for this?

Community Note

Terraform Version

1.3.9

AzureRM Provider Version

3.73.0

Affected Resource(s)/Data Source(s)

data - azurerm_servicebus_topic

Terraform Configuration Files

data "azurerm_servicebus_topic" "sb_topic" {
  name                = "topic1"
  resource_group_name = var.rg_name
  namespace_name      = var.namespace_name
}

resource "azurerm_servicebus_subscription" "sb" {
for_each = { for sub in var.servicebus_subscription_names: sub => sub }
name = each.key
topic_id = data.azurerm_servicebus_topic.sb_topic.id
max_delivery_count = var.max_count
lock_duration = var.lock_duration
}

Debug Output/Panic Output

# module.servicebus_subscription.azurerm_servicebus_subscription.subscription["sub3"] must be replaced
-/+ resource "azurerm_servicebus_subscription" "subscription" {
      ~ auto_delete_on_idle                       = "P10675199DT2H48M5.4775807S" -> (known after apply)
      - dead_lettering_on_message_expiration      = false -> null
      ~ default_message_ttl                       = "P10675199DT2H48M5.4775807S" -> (known after apply)
      - enable_batched_operations                 = false -> null
      ~ id                                        = "/subscriptions/sub/resourceGroups/rg/providers/Microsoft.ServiceBus/namespaces/namespace/topics/topic1/subscriptions/sub3" -> (known after apply)
        name                                      = "sub3"
      - requires_session                          = false -> null
      ~ topic_id                                  = "/subscriptions/sub/resourceGroups/rg/providers/Microsoft.ServiceBus/namespaces/namespace/topics/topic1" -> (known after apply) # forces replacement
        # (5 unchanged attributes hidden)
    }

  # module.servicebus_subscription.azurerm_servicebus_subscription.subscription["sub4"] must be replaced
-/+ resource "azurerm_servicebus_subscription" "subscription" {
      ~ auto_delete_on_idle                       = "P10675199DT2H48M5.4775807S" -> (known after apply)
      - dead_lettering_on_message_expiration      = false -> null
      ~ default_message_ttl                       = "P10675199DT2H48M5.4775807S" -> (known after apply)
      - enable_batched_operations                 = false -> null
      ~ id                                        = "/subscriptions/sub/resourceGroups/rg/providers/Microsoft.ServiceBus/namespaces/namespace/topics/topic1/subscriptions/sub4" -> (known after apply)
        name                                      = "sub4"
      - requires_session                          = false -> null
      ~ topic_id                                  = "/subscriptions/3c51cc28-d5df-44bb-b15c-cfdd64fff599/resourceGroups/RGTERRATEST-175246/providers/Microsoft.ServiceBus/namespaces/sb-175246-service-bus/topics/topic1" -> (known after apply) # forces replacement
        # (5 unchanged attributes hidden)
    }

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

Expected Behaviour

Terraform should not destroy and recreate the subscription.

Actual Behaviour

Terraform is attempting to recreate the service bus subscription(s) no matter how many times apply is run

Steps to Reproduce

  1. create relevant env variables, use Premium as the servicebus_sku
  2. Create a service bus namespace with a Premium_SKU and attempt to use that related topic in the creation of a service bus subscription

Important Factoids

No response

References

There was a similar bug/issue created, but was closed - #5131

chandra25111993 commented 3 months ago

Any update on this issue? We are also facing the same issue.

nitinprabhuhmcts commented 3 weeks ago

We are also facing same issue https://github.com/hmcts/sscs-shared-infrastructure/pull/186