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

azurerm_servicebus_topic enable_partitioning validation for Premium #26642

Open jaredfholgate opened 2 months ago

jaredfholgate commented 2 months ago

Is there an existing issue for this?

Community Note

Description

If enable_partitioning is set to true and the referenced Service Bus namespace is Premium SKU, the validation should fail and it should not attempt to create or update the Topic.

https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/servicebus_topic#enable_partitioning

The existing behaviour results in a plan to destroy and recreate the topic. The API then silently swallows the incorrect setting and the state still shows that enable_partitioning = false, even when desired state was true.

I appreciate this could is also an issue with how the API handles this, but it can be handled here in the provider to provide a better user experience.

New or Affected Resource(s)/Data Source(s)

azurerm_servicebus_topic

Potential Terraform Configuration

No change to existing configuration, just better validation.

References

None

xiaxyi commented 2 months ago

Thanks @jaredfholgate for raising this issue. As mentioned in the doc, partitioning for premium namespace can only be configured during the namespace creation, not during the topic creation. If the partitioning is not enabled for the parent namespace, may I know the reason of setting the partitioning to true for the queue? image

jaredfholgate commented 2 months ago

Hi. I agree it is there in the docs, but feedback from a Microsoft customer was that this is not enough. They had a production outage due to someone incorrectly setting this value and not reviewing the plan properly. I fully appreciate what I just said there and agree that this outage could easily have been avoided.

However the ask is to see if we can improve the provider given there is no other error shown in this scenario and the apply is not idempotent when this variable is set like this. Re-running the plan after an apply with this setting will result in another destroy and recreate plan.

xiaxyi commented 2 months ago

@jaredfholgate That makes sense, thanks for bringing this up to us. Let me check the api behavior and see if we can add a validation. I will update the progress here.

xiaxyi commented 1 month ago

@jaredfholgate I added the validation for servicebus topic entity, now there will be error if user tries to set the enable_partitioning to true for the non-partitioned namespace and vice versa. image

jaredfholgate commented 1 month ago

@jaredfholgate I added the validation for servicebus topic entity, now there will be error if user tries to set the enable_partitioning to true for the non-partitioned namespace and vice versa. image

Fantastic, thank you.