diff --git a/azurerm/resource_arm_servicebus_queue.go b/azurerm/resource_arm_servicebus_queue.go index dce867969e77..5d2c3ac96cfb 100644 --- a/azurerm/resource_arm_servicebus_queue.go +++ b/azurerm/resource_arm_servicebus_queue.go @@ -40,21 +40,24 @@ func resourceArmServiceBusQueue() *schema.Resource { "resource_group_name": resourceGroupNameSchema(), "auto_delete_on_idle": { - Type: schema.TypeString, - Optional: true, - Computed: true, + Type: schema.TypeString, + Optional: true, + Computed: true, + ValidateFunc: validateIso8601Duration(), }, "default_message_ttl": { - Type: schema.TypeString, - Optional: true, - Computed: true, + Type: schema.TypeString, + Optional: true, + Computed: true, + ValidateFunc: validateIso8601Duration(), }, "duplicate_detection_history_time_window": { - Type: schema.TypeString, - Optional: true, - Computed: true, + Type: schema.TypeString, + Optional: true, + Computed: true, + ValidateFunc: validateIso8601Duration(), }, "enable_express": { diff --git a/azurerm/resource_arm_servicebus_queue_test.go b/azurerm/resource_arm_servicebus_queue_test.go index 11e5c2a53b0c..b50fdeadaabe 100644 --- a/azurerm/resource_arm_servicebus_queue_test.go +++ b/azurerm/resource_arm_servicebus_queue_test.go @@ -230,6 +230,30 @@ func TestAccAzureRMServiceBusQueue_lockDuration(t *testing.T) { }) } +func TestAccAzureRMServiceBusQueue_isoTimeSpanAttributes(t *testing.T) { + resourceName := "azurerm_servicebus_queue.test" + ri := acctest.RandInt() + config := testAccAzureRMServiceBusQueue_isoTimeSpanAttributes(ri, testLocation()) + + resource.Test(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + Providers: testAccProviders, + CheckDestroy: testCheckAzureRMServiceBusQueueDestroy, + Steps: []resource.TestStep{ + { + Config: config, + Check: resource.ComposeTestCheckFunc( + testCheckAzureRMServiceBusQueueExists(resourceName), + resource.TestCheckResourceAttr(resourceName, "auto_delete_on_idle", "PT10M"), + resource.TestCheckResourceAttr(resourceName, "default_message_ttl", "PT30M"), + resource.TestCheckResourceAttr(resourceName, "requires_duplicate_detection", "true"), + resource.TestCheckResourceAttr(resourceName, "duplicate_detection_history_time_window", "PT15M"), + ), + }, + }, + }) +} + func testCheckAzureRMServiceBusQueueDestroy(s *terraform.State) error { client := testAccProvider.Meta().(*ArmClient).serviceBusQueuesClient ctx := testAccProvider.Meta().(*ArmClient).StopContext @@ -501,3 +525,29 @@ resource "azurerm_servicebus_queue" "test" { } `, rInt, location, rInt, rInt) } + +func testAccAzureRMServiceBusQueue_isoTimeSpanAttributes(rInt int, location string) string { + return fmt.Sprintf(` +resource "azurerm_resource_group" "test" { + name = "acctestRG-%d" + location = "%s" +} + +resource "azurerm_servicebus_namespace" "test" { + name = "acctestservicebusnamespace-%d" + resource_group_name = "${azurerm_resource_group.test.name}" + location = "${azurerm_resource_group.test.location}" + sku = "standard" +} + +resource "azurerm_servicebus_queue" "test" { + name = "acctestservicebusqueue-%d" + resource_group_name = "${azurerm_resource_group.test.name}" + namespace_name = "${azurerm_servicebus_namespace.test.name}" + auto_delete_on_idle = "PT10M" + default_message_ttl = "PT30M" + requires_duplicate_detection = true + duplicate_detection_history_time_window = "PT15M" +} +`, rInt, location, rInt, rInt) +} diff --git a/azurerm/resource_arm_servicebus_topic.go b/azurerm/resource_arm_servicebus_topic.go index dca3941bcd12..64d5dd85fe84 100644 --- a/azurerm/resource_arm_servicebus_topic.go +++ b/azurerm/resource_arm_servicebus_topic.go @@ -53,21 +53,24 @@ func resourceArmServiceBusTopic() *schema.Resource { }, "auto_delete_on_idle": { - Type: schema.TypeString, - Optional: true, - Computed: true, + Type: schema.TypeString, + Optional: true, + Computed: true, + ValidateFunc: validateIso8601Duration(), }, "default_message_ttl": { - Type: schema.TypeString, - Optional: true, - Computed: true, + Type: schema.TypeString, + Optional: true, + Computed: true, + ValidateFunc: validateIso8601Duration(), }, "duplicate_detection_history_time_window": { - Type: schema.TypeString, - Optional: true, - Computed: true, + Type: schema.TypeString, + Optional: true, + Computed: true, + ValidateFunc: validateIso8601Duration(), }, "enable_batched_operations": { diff --git a/azurerm/resource_arm_servicebus_topic_test.go b/azurerm/resource_arm_servicebus_topic_test.go index 33146c282ccf..8842af0c7082 100644 --- a/azurerm/resource_arm_servicebus_topic_test.go +++ b/azurerm/resource_arm_servicebus_topic_test.go @@ -201,6 +201,30 @@ func TestAccAzureRMServiceBusTopic_enableDuplicateDetection(t *testing.T) { }) } +func TestAccAzureRMServiceBusTopic_isoTimeSpanAttributes(t *testing.T) { + resourceName := "azurerm_servicebus_topic.test" + ri := acctest.RandInt() + config := testAccAzureRMServiceBusTopic_isoTimeSpanAttributes(ri, testLocation()) + + resource.Test(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + Providers: testAccProviders, + CheckDestroy: testCheckAzureRMServiceBusTopicDestroy, + Steps: []resource.TestStep{ + { + Config: config, + Check: resource.ComposeTestCheckFunc( + testCheckAzureRMServiceBusTopicExists(resourceName), + resource.TestCheckResourceAttr(resourceName, "auto_delete_on_idle", "PT10M"), + resource.TestCheckResourceAttr(resourceName, "default_message_ttl", "PT30M"), + resource.TestCheckResourceAttr(resourceName, "requires_duplicate_detection", "true"), + resource.TestCheckResourceAttr(resourceName, "duplicate_detection_history_time_window", "PT15M"), + ), + }, + }, + }) +} + func testCheckAzureRMServiceBusTopicDestroy(s *terraform.State) error { client := testAccProvider.Meta().(*ArmClient).serviceBusTopicsClient ctx := testAccProvider.Meta().(*ArmClient).StopContext @@ -425,3 +449,29 @@ resource "azurerm_servicebus_topic" "test" { } `, rInt, location, rInt, rInt) } + +func testAccAzureRMServiceBusTopic_isoTimeSpanAttributes(rInt int, location string) string { + return fmt.Sprintf(` +resource "azurerm_resource_group" "test" { + name = "acctestRG-%d" + location = "%s" +} + +resource "azurerm_servicebus_namespace" "test" { + name = "acctestservicebusnamespace-%d" + location = "${azurerm_resource_group.test.location}" + resource_group_name = "${azurerm_resource_group.test.name}" + sku = "standard" +} + +resource "azurerm_servicebus_topic" "test" { + name = "acctestservicebustopic-%d" + namespace_name = "${azurerm_servicebus_namespace.test.name}" + resource_group_name = "${azurerm_resource_group.test.name}" + auto_delete_on_idle = "PT10M" + default_message_ttl = "PT30M" + requires_duplicate_detection = true + duplicate_detection_history_time_window = "PT15M" +} +`, rInt, location, rInt, rInt) +} diff --git a/website/docs/r/servicebus_queue.html.markdown b/website/docs/r/servicebus_queue.html.markdown index 0127b37b7259..28bff27eb3ca 100644 --- a/website/docs/r/servicebus_queue.html.markdown +++ b/website/docs/r/servicebus_queue.html.markdown @@ -63,16 +63,14 @@ The following arguments are supported: * `resource_group_name` - (Required) The name of the resource group in which to create the namespace. Changing this forces a new resource to be created. -* `auto_delete_on_idle` - (Optional) The idle interval after which the - Queue is automatically deleted, minimum of 5 minutes. Provided in the [TimeSpan](#timespan-format) - format. +* `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. -* `default_message_ttl` - (Optional) The TTL of messages sent to this queue. This is the default value - used when TTL is not set on message itself. Provided in the [TimeSpan](#timespan-format) - format. +* `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. -* `duplicate_detection_history_time_window` - (Optional) The duration during which - duplicates can be detected. Default value is 10 minutes. Provided in the [TimeSpan](#timespan-format) format. +* `duplicate_detection_history_time_window` - (Optional) The ISO 8601 timespan duration during which + duplicates can be detected. Default value is 10 minutes. (`PT10M`) * `enable_express` - (Optional) Boolean flag which controls whether Express Entities are enabled. An express queue holds a message in memory temporarily before writing @@ -104,11 +102,6 @@ The following arguments are supported: Changing this forces a new resource to be created. Defaults to `false`. * `dead_lettering_on_message_expiration` - (Optional) Boolean flag which controls whether the Queue has dead letter support when a message expires. Defaults to `false`. - -### TimeSpan Format - -Some arguments for this resource are required in the TimeSpan format which is -used to represent a length of time. The supported format is documented [here](https://msdn.microsoft.com/en-us/library/se73z7b9(v=vs.110).aspx#Anchor_2) ## Attributes Reference diff --git a/website/docs/r/servicebus_topic.html.markdown b/website/docs/r/servicebus_topic.html.markdown index f2ce29ba6b27..8a89ea25425d 100644 --- a/website/docs/r/servicebus_topic.html.markdown +++ b/website/docs/r/servicebus_topic.html.markdown @@ -63,16 +63,14 @@ The following arguments are supported: * `status` - (Optional) The Status of the Service Bus Topic. Acceptable values are `Active` or `Disabled`. Defaults to `Active`. -* `auto_delete_on_idle` - (Optional) The idle interval after which the - Topic is automatically deleted, minimum of 5 minutes. Provided in the [TimeSpan](#timespan-format) - format. +* `auto_delete_on_idle` - (Optional) The ISO 8601 timespan duration of the idle interval after which the + Topic is automatically deleted, minimum of 5 minutes. -* `default_message_ttl` - (Optional) The TTL of messages sent to this topic if no - TTL value is set on the message itself. Provided in the [TimeSpan](#timespan-format) - format. +* `default_message_ttl` - (Optional) The ISO 8601 timespan duration of TTL of messages sent to this topic if no + TTL value is set on the message itself. -* `duplicate_detection_history_time_window` - (Optional) The duration during which - duplicates can be detected. Provided in the [TimeSpan](#timespan-format) format. Defaults to 10 minutes (`00:10:00`) +* `duplicate_detection_history_time_window` - (Optional) The ISO 8601 timespan duration during which + duplicates can be detected. Defaults to 10 minutes. (`PT10M`) * `enable_batched_operations` - (Optional) Boolean flag which controls if server-side batched operations are enabled. Defaults to false. @@ -98,11 +96,6 @@ The following arguments are supported: * `support_ordering` - (Optional) Boolean flag which controls whether the Topic supports ordering. Defaults to false. -### TimeSpan Format - -Some arguments for this resource are required in the TimeSpan format which is -used to represent a lengh of time. The supported format is documented [here](https://msdn.microsoft.com/en-us/library/se73z7b9(v=vs.110).aspx#Anchor_2) - ## Attributes Reference The following attributes are exported: