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

Add forward_to property to servicebus subscription resource #861

Merged
merged 5 commits into from
Feb 23, 2018
Merged
Show file tree
Hide file tree
Changes from 2 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
11 changes: 11 additions & 0 deletions azurerm/resource_arm_servicebus_subscription.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,12 @@ func resourceArmServiceBusSubscription() *schema.Resource {
ForceNew: true,
},

"forward_to": {
Type: schema.TypeString,
Optional: true,
Description: "The name of a Queue or Topic to automatically forward messages to.",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

as discussed on Slack, we don't generally specify the description for schema fields in the Azure Provider - we may in the future when there's a value for it (but there's no harm in leaving this in 😄)

},

// TODO: remove in the next major version
"dead_lettering_on_filter_evaluation_exceptions": {
Type: schema.TypeBool,
Expand Down Expand Up @@ -124,6 +130,10 @@ func resourceArmServiceBusSubscriptionCreate(d *schema.ResourceData, meta interf
parameters.SBSubscriptionProperties.LockDuration = &lockDuration
}

if forwardTo := d.Get("forward_to").(string); forwardTo != "" {
parameters.SBSubscriptionProperties.ForwardTo = &forwardTo
}

_, err := client.CreateOrUpdate(ctx, resourceGroup, namespaceName, topicName, name, parameters)
if err != nil {
return err
Expand Down Expand Up @@ -176,6 +186,7 @@ func resourceArmServiceBusSubscriptionRead(d *schema.ResourceData, meta interfac
d.Set("dead_lettering_on_message_expiration", props.DeadLetteringOnMessageExpiration)
d.Set("enable_batched_operations", props.EnableBatchedOperations)
d.Set("requires_session", props.RequiresSession)
d.Set("forward_to", props.ForwardTo)

if count := props.MaxDeliveryCount; count != nil {
d.Set("max_delivery_count", int(*count))
Expand Down
11 changes: 10 additions & 1 deletion azurerm/resource_arm_servicebus_subscription_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -173,9 +173,18 @@ resource "azurerm_servicebus_subscription" "test" {
namespace_name = "${azurerm_servicebus_namespace.test.name}"
topic_name = "${azurerm_servicebus_topic.test.name}"
resource_group_name = "${azurerm_resource_group.test.name}"
forward_to = "${azurerm_servicebus_topic.forward_to.name}"
max_delivery_count = 10
}
`, rInt, location, rInt, rInt, rInt)

resource "azurerm_servicebus_topic" "forward_to" {
name = "acctestservicebustopic-forward_to-%d"
namespace_name = "${azurerm_servicebus_namespace.test.name}"
resource_group_name = "${azurerm_resource_group.test.name}"
}


`, rInt, location, rInt, rInt, rInt, rInt)
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we make a specific test for forward to, since it's an optional field? we tend to use _basic to signify only the required fields


func testAccAzureRMServiceBusSubscription_update(rInt int, location string) string {
Expand Down
Binary file modified examples/servicebus-create-topic-and-subscription/graph.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
13 changes: 11 additions & 2 deletions examples/servicebus-create-topic-and-subscription/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ resource "azurerm_servicebus_namespace" "test" {
sku = "standard"
}


resource "azurerm_servicebus_topic" "test" {
name = "${var.unique}Topic"
location = "${var.location}"
resource_group_name = "${var.resource_group}"
namespace_name = "${azurerm_servicebus_namespace.test.name}"

Expand All @@ -29,9 +29,18 @@ resource "azurerm_servicebus_topic" "test" {

resource "azurerm_servicebus_subscription" "test" {
name = "${var.unique}Subscription"
location = "${var.location}"
resource_group_name = "${var.resource_group}"
namespace_name = "${azurerm_servicebus_namespace.test.name}"
topic_name = "${azurerm_servicebus_topic.test.name}"
forward_to = "${azurerm_servicebus_topic.forward_to.name}"
max_delivery_count = 1
}


resource "azurerm_servicebus_topic" "forward_to" {
name = "${var.unique}Topic-forward_to"
resource_group_name = "${var.resource_group}"
namespace_name = "${azurerm_servicebus_namespace.test.name}"

enable_partitioning = true
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,5 @@ variable "location" {
}

variable "unique" {
description = "a unique string that will be used to comprise the names of the Service Bus, Topic, and Subscription name spaces"
description = "A unique string that will be used to comprise the names of the Service Bus, Topic, and Subscription name spaces"
}
3 changes: 3 additions & 0 deletions website/docs/r/servicebus_subscription.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,9 @@ The following arguments are supported:
supports the concept of a session. Defaults to false. Changing this forces a
new resource to be created.

* `forward_to` - (Optional) The name of a Queue or Topic to automatically forward
messages to. Defaults to none.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can remove the Defaults to none section here


### TimeSpan Format

Some arguments for this resource are required in the TimeSpan format which is
Expand Down