Skip to content

Commit

Permalink
azurerm_eventhub - remove ForceNew and check partition_count is n…
Browse files Browse the repository at this point in the history
…ot decreased (hashicorp#23499)

* remove ForceNew and check partition_count is not decreased

* update doc
  • Loading branch information
catriona-m authored Oct 11, 2023
1 parent f125e45 commit 7eb1287
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
7 changes: 6 additions & 1 deletion internal/services/eventhub/eventhub_resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,6 @@ func resourceEventHub() *pluginsdk.Resource {
"partition_count": {
Type: pluginsdk.TypeInt,
Required: true,
ForceNew: true,
ValidateFunc: validate.ValidateEventHubPartitionCount,
},

Expand Down Expand Up @@ -222,6 +221,12 @@ func resourceEventHubUpdate(d *pluginsdk.ResourceData, meta interface{}) error {
id := eventhubs.NewEventhubID(subscriptionId, d.Get("resource_group_name").(string), d.Get("namespace_name").(string), d.Get("name").(string))

if d.HasChange("partition_count") {

o, n := d.GetChange("partition_count")
if o.(int) > n.(int) {
return fmt.Errorf("`partition_count` cannot be decreased")
}

client := meta.(*clients.Client).Eventhub.NamespacesClient
namespaceId := namespaces.NewNamespaceID(subscriptionId, id.ResourceGroupName, id.NamespaceName)
resp, err := client.Get(ctx, namespaceId)
Expand Down
4 changes: 2 additions & 2 deletions website/docs/r/eventhub.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,9 @@ The following arguments are supported:

* `resource_group_name` - (Required) The name of the resource group in which the EventHub's parent Namespace exists. Changing this forces a new resource to be created.

* `partition_count` - (Required) Specifies the current number of shards on the Event Hub. Changing this will force-recreate the resource.
* `partition_count` - (Required) Specifies the current number of shards on the Event Hub.

~> **Note:** `partition_count` cannot be changed unless Eventhub Namespace SKU is `Premium`.
~> **Note:** `partition_count` cannot be changed unless Eventhub Namespace SKU is `Premium` and cannot be decreased.

~> **Note:** When using a dedicated Event Hubs cluster, maximum value of `partition_count` is 1024. When using a shared parent EventHub Namespace, maximum value is 32.

Expand Down

0 comments on commit 7eb1287

Please sign in to comment.