Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

azurerm_servicebus_queue - fix defaults and remove 4.0 flags #27305

Merged
merged 1 commit into from
Sep 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
133 changes: 12 additions & 121 deletions internal/services/servicebus/servicebus_queue_resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ import (
"github.com/hashicorp/terraform-provider-azurerm/helpers/tf"
"github.com/hashicorp/terraform-provider-azurerm/helpers/validate"
"github.com/hashicorp/terraform-provider-azurerm/internal/clients"
"github.com/hashicorp/terraform-provider-azurerm/internal/features"
azValidate "github.com/hashicorp/terraform-provider-azurerm/internal/services/servicebus/validate"
"github.com/hashicorp/terraform-provider-azurerm/internal/tf/pluginsdk"
"github.com/hashicorp/terraform-provider-azurerm/internal/tf/validation"
Expand Down Expand Up @@ -48,7 +47,7 @@ func resourceServiceBusQueue() *pluginsdk.Resource {
}

func resourceServicebusQueueSchema() map[string]*pluginsdk.Schema {
schema := map[string]*pluginsdk.Schema{
return map[string]*pluginsdk.Schema{
"name": {
Type: pluginsdk.TypeString,
Required: true,
Expand All @@ -65,9 +64,10 @@ func resourceServicebusQueueSchema() map[string]*pluginsdk.Schema {
},

"auto_delete_on_idle": {
Type: pluginsdk.TypeString,
Optional: true,
Default: "P10675199DT2H48M5.4775807S", // Never
Type: pluginsdk.TypeString,
Optional: true,
// NOTE: O+C this gets a default except when using basic sku and can be updated without issues
Computed: true,
ValidateFunc: validate.ISO8601Duration,
},

Expand All @@ -78,9 +78,10 @@ func resourceServicebusQueueSchema() map[string]*pluginsdk.Schema {
},

"default_message_ttl": {
Type: pluginsdk.TypeString,
Optional: true,
Default: "P10675199DT2H48M5.4775807S", // Unbounded
Type: pluginsdk.TypeString,
Optional: true,
// NOTE: O+C this gets a default of "P10675199DT2H48M5.4775807S" (Unbounded) and "P14D" in Basic sku and can be updated without issues
Computed: true,
ValidateFunc: validate.ISO8601Duration,
},

Expand Down Expand Up @@ -181,84 +182,6 @@ func resourceServicebusQueueSchema() map[string]*pluginsdk.Schema {
}, false),
},
}

if !features.FourPointOhBeta() {
schema["auto_delete_on_idle"] = &pluginsdk.Schema{
Type: pluginsdk.TypeString,
Optional: true,
Computed: true,
ValidateFunc: validate.ISO8601Duration,
}

schema["default_message_ttl"] = &pluginsdk.Schema{
Type: pluginsdk.TypeString,
Optional: true,
Computed: true,
ValidateFunc: validate.ISO8601Duration,
}

schema["duplicate_detection_history_time_window"] = &pluginsdk.Schema{
Type: pluginsdk.TypeString,
Optional: true,
Computed: true,
ValidateFunc: validate.ISO8601Duration,
}

schema["enable_batched_operations"] = &pluginsdk.Schema{
Type: pluginsdk.TypeBool,
Optional: true,
Default: true,
ConflictsWith: []string{"batched_operations_enabled"},
Deprecated: "The property `enable_batched_operations` has been superseded by `batched_operations_enabled` and will be removed in v4.0 of the AzureRM Provider.",
}

schema["enable_express"] = &pluginsdk.Schema{
Type: pluginsdk.TypeBool,
Optional: true,
Default: false,
ConflictsWith: []string{"express_enabled"},
Deprecated: "The property `enable_express` has been superseded by `express_enabled` and will be removed in v4.0 of the AzureRM Provider.",
}

schema["enable_partitioning"] = &pluginsdk.Schema{
Type: pluginsdk.TypeBool,
Optional: true,
ForceNew: true,
Default: false,
ConflictsWith: []string{"partitioning_enabled"},
Deprecated: "The property `enable_partitioning` has been superseded by `partitioning_enabled` and will be removed in v4.0 of the AzureRM Provider.",
}

schema["batched_operations_enabled"] = &pluginsdk.Schema{
Type: pluginsdk.TypeBool,
Optional: true,
Computed: true,
ConflictsWith: []string{"enable_batched_operations"},
}

schema["express_enabled"] = &pluginsdk.Schema{
Type: pluginsdk.TypeBool,
Optional: true,
Computed: true,
ConflictsWith: []string{"enable_express"},
}

schema["partitioning_enabled"] = &pluginsdk.Schema{
Type: pluginsdk.TypeBool,
Optional: true,
Computed: true,
ForceNew: true,
ConflictsWith: []string{"enable_partitioning"},
}

schema["lock_duration"] = &pluginsdk.Schema{
Type: pluginsdk.TypeString,
Optional: true,
Computed: true,
}
}

return schema
}

func resourceServiceBusQueueCreateUpdate(d *pluginsdk.ResourceData, meta interface{}) error {
Expand Down Expand Up @@ -323,35 +246,9 @@ func resourceServiceBusQueueCreateUpdate(d *pluginsdk.ResourceData, meta interfa
userConfig["autoDeleteOnIdle"] = autoDeleteOnIdle
duplicateDetectionHistoryTimeWindow := d.Get("duplicate_detection_history_time_window").(string)

enableExpress := false
enablePartitioning := false
enableBatchedOperations := true
if v := d.GetRawConfig().AsValueMap()["express_enabled"]; !v.IsNull() {
enableExpress = d.Get("express_enabled").(bool)
}

if v := d.GetRawConfig().AsValueMap()["partitioning_enabled"]; !v.IsNull() {
enablePartitioning = d.Get("partitioning_enabled").(bool)
}

if v := d.GetRawConfig().AsValueMap()["batched_operations_enabled"]; !v.IsNull() {
enableBatchedOperations = d.Get("batched_operations_enabled").(bool)
}

if !features.FourPointOhBeta() {

if v := d.GetRawConfig().AsValueMap()["enable_express"]; !v.IsNull() {
enableExpress = d.Get("enable_express").(bool)
}

if v := d.GetRawConfig().AsValueMap()["enable_partitioning"]; !v.IsNull() {
enablePartitioning = d.Get("enable_partitioning").(bool)
}

if v := d.GetRawConfig().AsValueMap()["enable_batched_operations"]; !v.IsNull() {
enableBatchedOperations = d.Get("enable_batched_operations").(bool)
}
}
enableExpress := d.Get("express_enabled").(bool)
enablePartitioning := d.Get("partitioning_enabled").(bool)
enableBatchedOperations := d.Get("batched_operations_enabled").(bool)

userConfig["enableExpress"] = enableExpress
userConfig["enablePartitioning"] = enablePartitioning
Expand Down Expand Up @@ -496,12 +393,6 @@ func resourceServiceBusQueueRead(d *pluginsdk.ResourceData, meta interface{}) er
d.Set("requires_session", props.RequiresSession)
d.Set("status", string(pointer.From(props.Status)))

if !features.FourPointOhBeta() {
d.Set("enable_batched_operations", props.EnableBatchedOperations)
d.Set("enable_express", props.EnableExpress)
d.Set("enable_partitioning", props.EnablePartitioning)
}

d.Set("batched_operations_enabled", props.EnableBatchedOperations)
d.Set("express_enabled", props.EnableExpress)
d.Set("partitioning_enabled", props.EnablePartitioning)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -406,7 +406,7 @@ resource "azurerm_servicebus_namespace" "test" {
name = "acctestservicebusnamespace-%d"
resource_group_name = azurerm_resource_group.test.name
location = azurerm_resource_group.test.location
sku = "Standard"
sku = "Basic"
}

resource "azurerm_servicebus_queue" "test" {
Expand Down
8 changes: 4 additions & 4 deletions website/docs/r/servicebus_queue.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -47,15 +47,15 @@ The following arguments are supported:

* `lock_duration` - (Optional) The ISO 8601 timespan duration of a peek-lock; that is, the amount of time that the message is locked for other receivers. Maximum value is 5 minutes. Defaults to `PT1M` (1 Minute).

* `max_message_size_in_kilobytes` - (Optional) Integer value which controls the maximum size of a message allowed on the queue for Premium SKU. For supported values see the "Large messages support" section of [this document](https://docs.microsoft.com/azure/service-bus-messaging/service-bus-premium-messaging#large-messages-support-preview). Defaults to `256`.
* `max_message_size_in_kilobytes` - (Optional) Integer value which controls the maximum size of a message allowed on the queue for Premium SKU. For supported values see the "Large messages support" section of [this document](https://docs.microsoft.com/azure/service-bus-messaging/service-bus-premium-messaging#large-messages-support-preview).

* `max_size_in_megabytes` - (Optional) Integer value which controls the size of memory allocated for the queue. For supported values see the "Queue or topic size" section of [Service Bus Quotas](https://docs.microsoft.com/azure/service-bus-messaging/service-bus-quotas). Defaults to `5120`.
* `max_size_in_megabytes` - (Optional) Integer value which controls the size of memory allocated for the queue. For supported values see the "Queue or topic size" section of [Service Bus Quotas](https://docs.microsoft.com/azure/service-bus-messaging/service-bus-quotas).

* `requires_duplicate_detection` - (Optional) Boolean flag which controls whether the Queue requires duplicate detection. Changing this forces a new resource to be created. Defaults to `false`.

* `requires_session` - (Optional) Boolean flag which controls whether the Queue requires sessions. This will allow ordered handling of unbounded sequences of related messages. With sessions enabled a queue can guarantee first-in-first-out delivery of messages. Changing this forces a new resource to be created. Defaults to `false`.

* `default_message_ttl` - (Optional) The ISO 8601 timespan duration of the TTL of messages sent to this queue. This is the default value used when TTL is not set on message itself. Defaults to `P10675199DT2H48M5.4775807S`.
* `default_message_ttl` - (Optional) The ISO 8601 timespan duration of the TTL of messages sent to this queue. This is the default value used when TTL is not set on message itself.

* `dead_lettering_on_message_expiration` - (Optional) Boolean flag which controls whether the Queue has dead letter support when a message expires. Defaults to `false`.

Expand All @@ -67,7 +67,7 @@ The following arguments are supported:

* `batched_operations_enabled` - (Optional) Boolean flag which controls whether server-side batched operations are enabled. Defaults to `true`.

* `auto_delete_on_idle` - (Optional) The ISO 8601 timespan duration of the idle interval after which the Queue is automatically deleted, minimum of 5 minutes. Defaults to `P10675199DT2H48M5.4775807S`.
* `auto_delete_on_idle` - (Optional) The ISO 8601 timespan duration of the idle interval after which the Queue is automatically deleted, minimum of 5 minutes.

* `partitioning_enabled` - (Optional) Boolean flag which controls whether to enable the queue to be partitioned across multiple message brokers. Changing this forces a new resource to be created. Defaults to `false` for Basic and Standard.

Expand Down
Loading