Skip to content

Commit

Permalink
Fixes #8402
Browse files Browse the repository at this point in the history
  • Loading branch information
mbfrahry authored Sep 10, 2020
1 parent cd0f4b8 commit cd502dd
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,12 @@ func resourceArmServiceBusSubscription() *schema.Resource {
Optional: true,
},

"dead_lettering_on_filter_evaluation_error": {
Type: schema.TypeBool,
Optional: true,
Default: true,
},

"enable_batched_operations": {
Type: schema.TypeBool,
Optional: true,
Expand Down Expand Up @@ -132,11 +138,6 @@ func resourceArmServiceBusSubscriptionCreateUpdate(d *schema.ResourceData, meta
namespaceName := d.Get("namespace_name").(string)
resourceGroup := d.Get("resource_group_name").(string)

deadLetteringExpiration := d.Get("dead_lettering_on_message_expiration").(bool)
enableBatchedOps := d.Get("enable_batched_operations").(bool)
maxDeliveryCount := int32(d.Get("max_delivery_count").(int))
requiresSession := d.Get("requires_session").(bool)

if d.IsNewResource() {
existing, err := client.Get(ctx, resourceGroup, namespaceName, topicName, name)
if err != nil {
Expand All @@ -152,11 +153,12 @@ func resourceArmServiceBusSubscriptionCreateUpdate(d *schema.ResourceData, meta

parameters := servicebus.SBSubscription{
SBSubscriptionProperties: &servicebus.SBSubscriptionProperties{
DeadLetteringOnMessageExpiration: &deadLetteringExpiration,
EnableBatchedOperations: &enableBatchedOps,
MaxDeliveryCount: &maxDeliveryCount,
RequiresSession: &requiresSession,
Status: servicebus.EntityStatus(d.Get("status").(string)),
DeadLetteringOnMessageExpiration: utils.Bool(d.Get("dead_lettering_on_message_expiration").(bool)),
DeadLetteringOnFilterEvaluationExceptions: utils.Bool(d.Get("dead_lettering_on_filter_evaluation_error").(bool)),
EnableBatchedOperations: utils.Bool(d.Get("enable_batched_operations").(bool)),
MaxDeliveryCount: utils.Int32(int32(d.Get("max_delivery_count").(int))),
RequiresSession: utils.Bool(d.Get("requires_session").(bool)),
Status: servicebus.EntityStatus(d.Get("status").(string)),
},
}

Expand Down Expand Up @@ -230,6 +232,7 @@ func resourceArmServiceBusSubscriptionRead(d *schema.ResourceData, meta interfac
d.Set("default_message_ttl", props.DefaultMessageTimeToLive)
d.Set("lock_duration", props.LockDuration)
d.Set("dead_lettering_on_message_expiration", props.DeadLetteringOnMessageExpiration)
d.Set("dead_lettering_on_filter_evaluation_error", props.DeadLetteringOnFilterEvaluationExceptions)
d.Set("enable_batched_operations", props.EnableBatchedOperations)
d.Set("requires_session", props.RequiresSession)
d.Set("forward_to", props.ForwardTo)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,31 @@ func TestAccAzureRMServiceBusSubscription_updateForwardDeadLetteredMessagesTo(t
})
}

func TestAccAzureRMServiceBusSubscription_updateDeadLetteringOnFilterEvaluationExceptions(t *testing.T) {
data := acceptance.BuildTestData(t, "azurerm_servicebus_subscription", "test")

resource.ParallelTest(t, resource.TestCase{
PreCheck: func() { acceptance.PreCheck(t) },
Providers: acceptance.SupportedProviders,
CheckDestroy: testCheckAzureRMServiceBusSubscriptionDestroy,
Steps: []resource.TestStep{
{
Config: testAccAzureRMServiceBusSubscription_basic(data),
Check: resource.ComposeTestCheckFunc(
testCheckAzureRMServiceBusSubscriptionExists(data.ResourceName),
),
},
{
Config: testAccAzureRMServiceBusSubscription_updateDeadLetteringOnFilterEvaluationExceptions(data),
Check: resource.ComposeTestCheckFunc(
testCheckAzureRMServiceBusSubscriptionExists(data.ResourceName),
),
},
data.ImportStep(),
},
})
}

func TestAccAzureRMServiceBusSubscription_status(t *testing.T) {
data := acceptance.BuildTestData(t, "azurerm_servicebus_subscription", "test")

Expand Down Expand Up @@ -367,3 +392,8 @@ func testAccAzureRMServiceBusSubscription_status(data acceptance.TestData, statu
return fmt.Sprintf(testAccAzureRMServiceBusSubscription_tfTemplate, data.RandomInteger, data.Locations.Primary, data.RandomInteger, data.RandomInteger, data.RandomInteger,
fmt.Sprintf("status = \"%s\"", status))
}

func testAccAzureRMServiceBusSubscription_updateDeadLetteringOnFilterEvaluationExceptions(data acceptance.TestData) string {
return fmt.Sprintf(testAccAzureRMServiceBusSubscription_tfTemplate, data.RandomInteger, data.Locations.Primary, data.RandomInteger, data.RandomInteger, data.RandomInteger,
"dead_lettering_on_filter_evaluation_error = false\n")
}
2 changes: 2 additions & 0 deletions website/docs/r/servicebus_subscription.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,8 @@ The following arguments are supported:

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

* `dead_lettering_on_filter_evaluation_error` - (Optional) Boolean flag which controls whether the Subscription has dead letter support on filter evaluation exceptions. Defaults to `true`.

* `enable_batched_operations` - (Optional) Boolean flag which controls whether the Subscription supports batched operations. Defaults to `false`.

* `requires_session` - (Optional) Boolean flag which controls whether this Subscription supports the concept of a session. Defaults to `false`. Changing this forces a new resource to be created.
Expand Down

0 comments on commit cd502dd

Please sign in to comment.