From 5fe1348aadf9777f86f032d019db6272fc146374 Mon Sep 17 00:00:00 2001 From: kt Date: Tue, 24 Jul 2018 09:40:28 -0700 Subject: [PATCH 1/2] azurerm_servicebus_topic name now allows ~s --- azurerm/helpers/azure/servicebus.go | 2 +- azurerm/resource_arm_servicebus_topic.go | 7 ++++--- examples/servicebus/main.tf | 2 +- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/azurerm/helpers/azure/servicebus.go b/azurerm/helpers/azure/servicebus.go index e0e319d0adfe..175150f0e988 100644 --- a/azurerm/helpers/azure/servicebus.go +++ b/azurerm/helpers/azure/servicebus.go @@ -35,7 +35,7 @@ func ValidateServiceBusSubscriptionName() schema.SchemaValidateFunc { func ValidateServiceBusTopicName() schema.SchemaValidateFunc { return validation.StringMatch( - regexp.MustCompile("^[a-zA-Z][-._a-zA-Z0-9]{0,258}([a-zA-Z0-9])?$"), + regexp.MustCompile("^[a-zA-Z][-._~a-zA-Z0-9]{0,258}([a-zA-Z0-9])?$"), "The topic name can contain only letters, numbers, periods, hyphens and underscores. The namespace must start with a letter, and it must end with a letter or number and be less then 260 characters long.", ) } diff --git a/azurerm/resource_arm_servicebus_topic.go b/azurerm/resource_arm_servicebus_topic.go index 52788192a31b..dca3941bcd12 100644 --- a/azurerm/resource_arm_servicebus_topic.go +++ b/azurerm/resource_arm_servicebus_topic.go @@ -24,9 +24,10 @@ func resourceArmServiceBusTopic() *schema.Resource { Schema: map[string]*schema.Schema{ "name": { - Type: schema.TypeString, - Required: true, - ForceNew: true, + Type: schema.TypeString, + Required: true, + ForceNew: true, + ValidateFunc: azure.ValidateServiceBusTopicName(), }, "namespace_name": { diff --git a/examples/servicebus/main.tf b/examples/servicebus/main.tf index 1f17fe2f71ec..fcb25c39e607 100644 --- a/examples/servicebus/main.tf +++ b/examples/servicebus/main.tf @@ -26,7 +26,7 @@ resource "azurerm_servicebus_namespace_authorization_rule" "example" { } resource "azurerm_servicebus_topic" "source" { - name = "tfex_servicebus${random_integer.ri.result}_topic" + name = "tfex_servicebus${random_integer.ri.result}~topic" resource_group_name = "${azurerm_resource_group.example.name}" namespace_name = "${azurerm_servicebus_namespace.example.name}" From ca94af645a0500e967288990894a68e5861e293c Mon Sep 17 00:00:00 2001 From: kt Date: Tue, 24 Jul 2018 14:57:19 -0700 Subject: [PATCH 2/2] Amended service bus topic name validation error message to include ~ --- azurerm/helpers/azure/servicebus.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/azurerm/helpers/azure/servicebus.go b/azurerm/helpers/azure/servicebus.go index 175150f0e988..c19879662b3d 100644 --- a/azurerm/helpers/azure/servicebus.go +++ b/azurerm/helpers/azure/servicebus.go @@ -36,7 +36,7 @@ func ValidateServiceBusSubscriptionName() schema.SchemaValidateFunc { func ValidateServiceBusTopicName() schema.SchemaValidateFunc { return validation.StringMatch( regexp.MustCompile("^[a-zA-Z][-._~a-zA-Z0-9]{0,258}([a-zA-Z0-9])?$"), - "The topic name can contain only letters, numbers, periods, hyphens and underscores. The namespace must start with a letter, and it must end with a letter or number and be less then 260 characters long.", + "The topic name can contain only letters, numbers, periods, hyphens, tildas and underscores. The namespace must start with a letter, and it must end with a letter or number and be less then 260 characters long.", ) }