From b1fcd204cf31dbf94f700d529f1defd3ee29e9fd Mon Sep 17 00:00:00 2001 From: kt Date: Sun, 15 Jul 2018 04:38:03 -0700 Subject: [PATCH] New Resource - resource_arm_servicebus_queue_authorization_rule (#1543) New Resource - azurerm_servicebus_queue_authorization_rule --- azurerm/helpers/azure/servicebus.go | 75 +++++++ ...ervicebus_topic_authorization_rule_test.go | 104 --------- azurerm/provider.go | 1 + ...servicebus_namespace_authorization_rule.go | 51 +---- ...cebus_namespace_authorization_rule_test.go | 3 +- azurerm/resource_arm_servicebus_queue.go | 8 +- ...arm_servicebus_queue_authorization_rule.go | 157 +++++++++++++ ...ervicebus_queue_authorization_rule_test.go | 194 ++++++++++++++++ .../resource_arm_servicebus_subscription.go | 14 +- ...source_arm_servicebus_subscription_rule.go | 14 +- ...arm_servicebus_topic_authorization_rule.go | 46 +--- ...ervicebus_topic_authorization_rule_test.go | 211 ++++++------------ examples/servicebus/main.tf | 45 +++- website/azurerm.erb | 6 +- ...bus_queue_authorization_rule.html.markdown | 94 ++++++++ 15 files changed, 657 insertions(+), 366 deletions(-) delete mode 100644 azurerm/import_arm_servicebus_topic_authorization_rule_test.go create mode 100644 azurerm/resource_arm_servicebus_queue_authorization_rule.go create mode 100644 azurerm/resource_arm_servicebus_queue_authorization_rule_test.go create mode 100644 website/docs/r/servicebus_queue_authorization_rule.html.markdown diff --git a/azurerm/helpers/azure/servicebus.go b/azurerm/helpers/azure/servicebus.go index d7508c83ab44..e0e319d0adfe 100644 --- a/azurerm/helpers/azure/servicebus.go +++ b/azurerm/helpers/azure/servicebus.go @@ -19,6 +19,20 @@ func ValidateServiceBusNamespaceName() schema.SchemaValidateFunc { ) } +func ValidateServiceBusQueueName() schema.SchemaValidateFunc { + return validation.StringMatch( + regexp.MustCompile(`^[a-zA-Z0-9][\w-./~]{0,258}([a-zA-Z0-9])?$`), + "The topic name can contain only letters, numbers, periods, hyphens, tildas, forward slashes and underscores. The namespace must start and end with a letter or number and be less then 260 characters long.", + ) +} + +func ValidateServiceBusSubscriptionName() schema.SchemaValidateFunc { + return validation.StringMatch( + regexp.MustCompile("^[a-zA-Z][-._a-zA-Z0-9]{0,48}([a-zA-Z0-9])?$"), + "The name can contain only letters, numbers, periods, hyphens and underscores. The name must start and end with a letter or number and be less then 50 characters long.", + ) +} + func ValidateServiceBusTopicName() schema.SchemaValidateFunc { return validation.StringMatch( regexp.MustCompile("^[a-zA-Z][-._a-zA-Z0-9]{0,258}([a-zA-Z0-9])?$"), @@ -73,6 +87,67 @@ func FlattenServiceBusAuthorizationRuleRights(rights *[]servicebus.AccessRights) } //shared schema +func MergeSchema(a map[string]*schema.Schema, b map[string]*schema.Schema) map[string]*schema.Schema { + s := map[string]*schema.Schema{} + + for k, v := range a { + s[k] = v + } + + for k, v := range b { + s[k] = v + } + + return s +} + +func ServiceBusAuthorizationRuleSchemaFrom(s map[string]*schema.Schema) map[string]*schema.Schema { + + authSchema := map[string]*schema.Schema{ + "listen": { + Type: schema.TypeBool, + Optional: true, + Default: false, + }, + + "send": { + Type: schema.TypeBool, + Optional: true, + Default: false, + }, + + "manage": { + Type: schema.TypeBool, + Optional: true, + Default: false, + }, + + "primary_key": { + Type: schema.TypeString, + Computed: true, + Sensitive: true, + }, + + "primary_connection_string": { + Type: schema.TypeString, + Computed: true, + Sensitive: true, + }, + + "secondary_key": { + Type: schema.TypeString, + Computed: true, + Sensitive: true, + }, + + "secondary_connection_string": { + Type: schema.TypeString, + Computed: true, + Sensitive: true, + }, + } + return MergeSchema(s, authSchema) +} func ServiceBusAuthorizationRuleCustomizeDiff(d *schema.ResourceDiff, _ interface{}) error { listen, hasListen := d.GetOk("listen") diff --git a/azurerm/import_arm_servicebus_topic_authorization_rule_test.go b/azurerm/import_arm_servicebus_topic_authorization_rule_test.go deleted file mode 100644 index 0eb3a0d3a348..000000000000 --- a/azurerm/import_arm_servicebus_topic_authorization_rule_test.go +++ /dev/null @@ -1,104 +0,0 @@ -package azurerm - -import ( - "testing" - - "github.com/hashicorp/terraform/helper/acctest" - "github.com/hashicorp/terraform/helper/resource" -) - -func TestAccAzureRMServiceBusTopicAuthorizationRule_importListen(t *testing.T) { - resourceName := "azurerm_servicebus_topic_authorization_rule.test" - - ri := acctest.RandInt() - config := testAccAzureRMServiceBusTopicAuthorizationRule_listen(ri, testLocation()) - - resource.Test(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - Providers: testAccProviders, - CheckDestroy: testCheckAzureRMServiceBusTopicAuthorizationRuleDestroy, - Steps: []resource.TestStep{ - { - Config: config, - }, - - { - ResourceName: resourceName, - ImportState: true, - ImportStateVerify: true, - }, - }, - }) -} - -func TestAccAzureRMServiceBusTopicAuthorizationRule_importSend(t *testing.T) { - resourceName := "azurerm_servicebus_topic_authorization_rule.test" - - ri := acctest.RandInt() - config := testAccAzureRMServiceBusTopicAuthorizationRule_send(ri, testLocation()) - - resource.Test(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - Providers: testAccProviders, - CheckDestroy: testCheckAzureRMServiceBusTopicAuthorizationRuleDestroy, - Steps: []resource.TestStep{ - { - Config: config, - }, - - { - ResourceName: resourceName, - ImportState: true, - ImportStateVerify: true, - }, - }, - }) -} - -func TestAccAzureRMServiceBusTopicAuthorizationRule_importReadWrite(t *testing.T) { - resourceName := "azurerm_servicebus_topic_authorization_rule.test" - - ri := acctest.RandInt() - config := testAccAzureRMServiceBusTopicAuthorizationRule_readWrite(ri, testLocation()) - - resource.Test(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - Providers: testAccProviders, - CheckDestroy: testCheckAzureRMServiceBusTopicAuthorizationRuleDestroy, - Steps: []resource.TestStep{ - { - Config: config, - }, - - { - ResourceName: resourceName, - ImportState: true, - ImportStateVerify: true, - }, - }, - }) -} - -func TestAccAzureRMServiceBusTopicAuthorizationRule_importManage(t *testing.T) { - resourceName := "azurerm_servicebus_topic_authorization_rule.test" - - ri := acctest.RandInt() - config := testAccAzureRMServiceBusTopicAuthorizationRule_manage(ri, testLocation()) - - resource.Test(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - Providers: testAccProviders, - CheckDestroy: testCheckAzureRMServiceBusTopicAuthorizationRuleDestroy, - Steps: []resource.TestStep{ - { - Config: config, - }, - - { - ResourceName: resourceName, - ImportState: true, - ImportStateVerify: true, - }, - }, - }) -} diff --git a/azurerm/provider.go b/azurerm/provider.go index 235e6f607d7f..1baf6908822b 100644 --- a/azurerm/provider.go +++ b/azurerm/provider.go @@ -207,6 +207,7 @@ func Provider() terraform.ResourceProvider { "azurerm_servicebus_namespace": resourceArmServiceBusNamespace(), "azurerm_servicebus_namespace_authorization_rule": resourceArmServiceBusNamespaceAuthorizationRule(), "azurerm_servicebus_queue": resourceArmServiceBusQueue(), + "azurerm_servicebus_queue_authorization_rule": resourceArmServiceBusQueueAuthorizationRule(), "azurerm_servicebus_subscription": resourceArmServiceBusSubscription(), "azurerm_servicebus_subscription_rule": resourceArmServiceBusSubscriptionRule(), "azurerm_servicebus_topic": resourceArmServiceBusTopic(), diff --git a/azurerm/resource_arm_servicebus_namespace_authorization_rule.go b/azurerm/resource_arm_servicebus_namespace_authorization_rule.go index d2147c265309..065709010b52 100644 --- a/azurerm/resource_arm_servicebus_namespace_authorization_rule.go +++ b/azurerm/resource_arm_servicebus_namespace_authorization_rule.go @@ -10,10 +10,6 @@ import ( "github.com/terraform-providers/terraform-provider-azurerm/azurerm/utils" ) -func resourceArmServiceAuthRuleSchemaFrom(schema map[string]*schema.Schema) map[string]*schema.Schema { - return schema -} - func resourceArmServiceBusNamespaceAuthorizationRule() *schema.Resource { return &schema.Resource{ Create: resourceArmServiceBusNamespaceAuthorizationRuleCreateUpdate, @@ -25,7 +21,8 @@ func resourceArmServiceBusNamespaceAuthorizationRule() *schema.Resource { State: schema.ImportStatePassthrough, }, - Schema: resourceArmServiceAuthRuleSchemaFrom(map[string]*schema.Schema{ + //function takes a schema map and adds the authorization rule properties to it + Schema: azure.ServiceBusAuthorizationRuleSchemaFrom(map[string]*schema.Schema{ "name": { Type: schema.TypeString, Required: true, @@ -41,48 +38,6 @@ func resourceArmServiceBusNamespaceAuthorizationRule() *schema.Resource { }, "resource_group_name": resourceGroupNameSchema(), - - "listen": { - Type: schema.TypeBool, - Optional: true, - Default: false, - }, - - "send": { - Type: schema.TypeBool, - Optional: true, - Default: false, - }, - - "manage": { - Type: schema.TypeBool, - Optional: true, - Default: false, - }, - - "primary_key": { - Type: schema.TypeString, - Computed: true, - Sensitive: true, - }, - - "primary_connection_string": { - Type: schema.TypeString, - Computed: true, - Sensitive: true, - }, - - "secondary_key": { - Type: schema.TypeString, - Computed: true, - Sensitive: true, - }, - - "secondary_connection_string": { - Type: schema.TypeString, - Computed: true, - Sensitive: true, - }, }), CustomizeDiff: azure.ServiceBusAuthorizationRuleCustomizeDiff, @@ -182,7 +137,7 @@ func resourceArmServiceBusNamespaceAuthorizationRuleDelete(d *schema.ResourceDat resGroup := id.ResourceGroup namespaceName := id.Path["namespaces"] - name := id.Path["AuthorizationRules"] //this is slightly different then topic (Authorization vs authorization) + name := id.Path["AuthorizationRules"] //this is slightly different then topic/queue (Authorization vs authorization) if _, err = client.DeleteAuthorizationRule(ctx, resGroup, namespaceName, name); err != nil { return fmt.Errorf("Error issuing Azure ARM delete request of ServiceBus Namespace Authorization Rule %q (Resource Group %q): %+v", name, resGroup, err) diff --git a/azurerm/resource_arm_servicebus_namespace_authorization_rule_test.go b/azurerm/resource_arm_servicebus_namespace_authorization_rule_test.go index b1d014fa74cd..d3003fe8fd40 100644 --- a/azurerm/resource_arm_servicebus_namespace_authorization_rule_test.go +++ b/azurerm/resource_arm_servicebus_namespace_authorization_rule_test.go @@ -106,7 +106,7 @@ func testCheckAzureRMServiceBusNamespaceAuthorizationRuleDestroy(s *terraform.St ctx := testAccProvider.Meta().(*ArmClient).StopContext for _, rs := range s.RootModule().Resources { - if rs.Type != "azurerm_servicebus_topic_authorization_rule" { + if rs.Type != "azurerm_servicebus_namespace_authorization_rule" { continue } @@ -173,6 +173,7 @@ resource "azurerm_servicebus_namespace_authorization_rule" "test" { name = "acctest-%[1]d" namespace_name = "${azurerm_servicebus_namespace.test.name}" resource_group_name = "${azurerm_resource_group.test.name}" + listen = %[3]t send = %[4]t manage = %[5]t diff --git a/azurerm/resource_arm_servicebus_queue.go b/azurerm/resource_arm_servicebus_queue.go index 08e88eba6f8a..dce867969e77 100644 --- a/azurerm/resource_arm_servicebus_queue.go +++ b/azurerm/resource_arm_servicebus_queue.go @@ -22,9 +22,10 @@ func resourceArmServiceBusQueue() *schema.Resource { Schema: map[string]*schema.Schema{ "name": { - Type: schema.TypeString, - Required: true, - ForceNew: true, + Type: schema.TypeString, + Required: true, + ForceNew: true, + ValidateFunc: azure.ValidateServiceBusQueueName(), }, "namespace_name": { @@ -107,6 +108,7 @@ func resourceArmServiceBusQueue() *schema.Resource { Optional: true, Deprecated: "This field has been removed by Azure.", }, + "support_ordering": { Type: schema.TypeBool, Optional: true, diff --git a/azurerm/resource_arm_servicebus_queue_authorization_rule.go b/azurerm/resource_arm_servicebus_queue_authorization_rule.go new file mode 100644 index 000000000000..4ddca0e4ad6b --- /dev/null +++ b/azurerm/resource_arm_servicebus_queue_authorization_rule.go @@ -0,0 +1,157 @@ +package azurerm + +import ( + "fmt" + "log" + + "github.com/Azure/azure-sdk-for-go/services/servicebus/mgmt/2017-04-01/servicebus" + "github.com/hashicorp/terraform/helper/schema" + "github.com/terraform-providers/terraform-provider-azurerm/azurerm/helpers/azure" + "github.com/terraform-providers/terraform-provider-azurerm/azurerm/utils" +) + +func resourceArmServiceBusQueueAuthorizationRule() *schema.Resource { + return &schema.Resource{ + Create: resourceArmServiceBusQueueAuthorizationRuleCreateUpdate, + Read: resourceArmServiceBusQueueAuthorizationRuleRead, + Update: resourceArmServiceBusQueueAuthorizationRuleCreateUpdate, + Delete: resourceArmServiceBusQueueAuthorizationRuleDelete, + + Importer: &schema.ResourceImporter{ + State: schema.ImportStatePassthrough, + }, + + Schema: azure.ServiceBusAuthorizationRuleSchemaFrom(map[string]*schema.Schema{ + "name": { + Type: schema.TypeString, + Required: true, + ForceNew: true, + ValidateFunc: azure.ValidateServiceBusAuthorizationRuleName(), + }, + + "namespace_name": { + Type: schema.TypeString, + Required: true, + ForceNew: true, + ValidateFunc: azure.ValidateServiceBusNamespaceName(), + }, + + "queue_name": { + Type: schema.TypeString, + Required: true, + ForceNew: true, + ValidateFunc: azure.ValidateServiceBusQueueName(), + }, + + "resource_group_name": resourceGroupNameSchema(), + }), + + CustomizeDiff: azure.ServiceBusAuthorizationRuleCustomizeDiff, + } +} + +func resourceArmServiceBusQueueAuthorizationRuleCreateUpdate(d *schema.ResourceData, meta interface{}) error { + client := meta.(*ArmClient).serviceBusQueuesClient + ctx := meta.(*ArmClient).StopContext + + log.Printf("[INFO] preparing arguments for AzureRM ServiceBus Queue Authorization Rule creation.") + + name := d.Get("name").(string) + resGroup := d.Get("resource_group_name").(string) + namespaceName := d.Get("namespace_name").(string) + queueName := d.Get("queue_name").(string) + + parameters := servicebus.SBAuthorizationRule{ + Name: &name, + SBAuthorizationRuleProperties: &servicebus.SBAuthorizationRuleProperties{ + Rights: azure.ExpandServiceBusAuthorizationRuleRights(d), + }, + } + + _, err := client.CreateOrUpdateAuthorizationRule(ctx, resGroup, namespaceName, queueName, name, parameters) + if err != nil { + return err + } + + read, err := client.GetAuthorizationRule(ctx, resGroup, namespaceName, queueName, name) + if err != nil { + return err + } + + if read.ID == nil { + return fmt.Errorf("Cannot read ServiceBus Namespace Queue Authorization Rule %q (Queue %q / Namespace %q / Resource Group %q) ID", name, queueName, namespaceName, resGroup) + } + + d.SetId(*read.ID) + + return resourceArmServiceBusQueueAuthorizationRuleRead(d, meta) +} + +func resourceArmServiceBusQueueAuthorizationRuleRead(d *schema.ResourceData, meta interface{}) error { + client := meta.(*ArmClient).serviceBusQueuesClient + ctx := meta.(*ArmClient).StopContext + + id, err := parseAzureResourceID(d.Id()) + if err != nil { + return err + } + + resGroup := id.ResourceGroup + namespaceName := id.Path["namespaces"] + name := id.Path["authorizationRules"] + queueName := id.Path["queues"] + + resp, err := client.GetAuthorizationRule(ctx, resGroup, namespaceName, queueName, name) + if err != nil { + if utils.ResponseWasNotFound(resp.Response) { + d.SetId("") + return nil + } + return fmt.Errorf("Error making Read request on Azure ServiceBus Queue Authorization Rule %q (Queue %q / Namespace %q / Resource Group %q): %+v", name, queueName, namespaceName, resGroup, err) + } + + d.Set("name", name) + d.Set("resource_group_name", resGroup) + d.Set("namespace_name", namespaceName) + d.Set("queue_name", queueName) + + if properties := resp.SBAuthorizationRuleProperties; properties != nil { + listen, send, manage := azure.FlattenServiceBusAuthorizationRuleRights(properties.Rights) + d.Set("manage", manage) + d.Set("listen", listen) + d.Set("send", send) + } + + keysResp, err := client.ListKeys(ctx, resGroup, namespaceName, queueName, name) + if err != nil { + return fmt.Errorf("Error making Read request on Azure ServiceBus Queue Authorization Rule List Keys %q: %+v", name, err) + } + + d.Set("primary_key", keysResp.PrimaryKey) + d.Set("primary_connection_string", keysResp.PrimaryConnectionString) + d.Set("secondary_key", keysResp.SecondaryKey) + d.Set("secondary_connection_string", keysResp.SecondaryConnectionString) + + return nil +} + +func resourceArmServiceBusQueueAuthorizationRuleDelete(d *schema.ResourceData, meta interface{}) error { + client := meta.(*ArmClient).serviceBusQueuesClient + ctx := meta.(*ArmClient).StopContext + + id, err := parseAzureResourceID(d.Id()) + if err != nil { + return err + } + + resGroup := id.ResourceGroup + namespaceName := id.Path["namespaces"] + name := id.Path["authorizationRules"] + queueName := id.Path["queues"] + + if _, err = client.DeleteAuthorizationRule(ctx, resGroup, namespaceName, queueName, name); err != nil { + return fmt.Errorf("Error issuing delete request of ServiceBus Queue Authorization Rule %q (Queue %q / Namespace %q / Resource Group %q): %+v", name, queueName, namespaceName, resGroup, err) + } + + return nil +} diff --git a/azurerm/resource_arm_servicebus_queue_authorization_rule_test.go b/azurerm/resource_arm_servicebus_queue_authorization_rule_test.go new file mode 100644 index 000000000000..681816f99591 --- /dev/null +++ b/azurerm/resource_arm_servicebus_queue_authorization_rule_test.go @@ -0,0 +1,194 @@ +package azurerm + +import ( + "fmt" + "strconv" + "testing" + + "github.com/hashicorp/terraform/helper/acctest" + "github.com/hashicorp/terraform/helper/resource" + "github.com/hashicorp/terraform/terraform" + "github.com/terraform-providers/terraform-provider-azurerm/azurerm/utils" +) + +func TestAccAzureRMServiceBusQueueAuthorizationRule_listen(t *testing.T) { + testAccAzureRMServiceBusQueueAuthorizationRule(t, true, false, false) +} + +func TestAccAzureRMServiceBusQueueAuthorizationRule_send(t *testing.T) { + testAccAzureRMServiceBusQueueAuthorizationRule(t, false, true, false) +} + +func TestAccAzureRMServiceBusQueueAuthorizationRule_listensend(t *testing.T) { + testAccAzureRMServiceBusQueueAuthorizationRule(t, true, true, false) +} + +func TestAccAzureRMServiceBusQueueAuthorizationRule_manage(t *testing.T) { + testAccAzureRMServiceBusQueueAuthorizationRule(t, true, true, true) +} + +func testAccAzureRMServiceBusQueueAuthorizationRule(t *testing.T, listen, send, manage bool) { + resourceName := "azurerm_servicebus_queue_authorization_rule.test" + + resource.Test(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + Providers: testAccProviders, + CheckDestroy: testCheckAzureRMServiceBusQueueAuthorizationRuleDestroy, + Steps: []resource.TestStep{ + { + Config: testAccAzureRMServiceBusQueueAuthorizationRule_base(acctest.RandInt(), testLocation(), listen, send, manage), + Check: resource.ComposeTestCheckFunc( + testCheckAzureRMServiceBusQueueAuthorizationRuleExists(resourceName), + resource.TestCheckResourceAttrSet(resourceName, "name"), + resource.TestCheckResourceAttrSet(resourceName, "namespace_name"), + resource.TestCheckResourceAttrSet(resourceName, "queue_name"), + resource.TestCheckResourceAttrSet(resourceName, "primary_key"), + resource.TestCheckResourceAttrSet(resourceName, "secondary_key"), + resource.TestCheckResourceAttrSet(resourceName, "primary_connection_string"), + resource.TestCheckResourceAttrSet(resourceName, "secondary_connection_string"), + resource.TestCheckResourceAttr(resourceName, "listen", strconv.FormatBool(listen)), + resource.TestCheckResourceAttr(resourceName, "send", strconv.FormatBool(send)), + resource.TestCheckResourceAttr(resourceName, "manage", strconv.FormatBool(manage)), + ), + }, + { + ResourceName: resourceName, + ImportState: true, + ImportStateVerify: true, + }, + }, + }) +} + +func TestAccAzureRMServiceBusQueueAuthorizationRule_rightsUpdate(t *testing.T) { + resourceName := "azurerm_servicebus_queue_authorization_rule.test" + + resource.Test(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + Providers: testAccProviders, + CheckDestroy: testCheckAzureRMServiceBusQueueAuthorizationRuleDestroy, + Steps: []resource.TestStep{ + { + Config: testAccAzureRMServiceBusQueueAuthorizationRule_base(acctest.RandInt(), testLocation(), true, false, false), + Check: resource.ComposeTestCheckFunc( + testCheckAzureRMServiceBusQueueAuthorizationRuleExists(resourceName), + resource.TestCheckResourceAttr(resourceName, "listen", "true"), + resource.TestCheckResourceAttr(resourceName, "send", "false"), + resource.TestCheckResourceAttr(resourceName, "manage", "false"), + ), + }, + { + Config: testAccAzureRMServiceBusQueueAuthorizationRule_base(acctest.RandInt(), testLocation(), true, true, true), + Check: resource.ComposeTestCheckFunc( + testCheckAzureRMServiceBusQueueAuthorizationRuleExists(resourceName), + resource.TestCheckResourceAttrSet(resourceName, "name"), + resource.TestCheckResourceAttrSet(resourceName, "namespace_name"), + resource.TestCheckResourceAttrSet(resourceName, "primary_key"), + resource.TestCheckResourceAttrSet(resourceName, "secondary_key"), + resource.TestCheckResourceAttrSet(resourceName, "primary_connection_string"), + resource.TestCheckResourceAttrSet(resourceName, "secondary_connection_string"), + resource.TestCheckResourceAttr(resourceName, "listen", "true"), + resource.TestCheckResourceAttr(resourceName, "send", "true"), + resource.TestCheckResourceAttr(resourceName, "manage", "true"), + ), + }, + { + ResourceName: resourceName, + ImportState: true, + ImportStateVerify: true, + }, + }, + }) +} + +func testCheckAzureRMServiceBusQueueAuthorizationRuleDestroy(s *terraform.State) error { + conn := testAccProvider.Meta().(*ArmClient).serviceBusQueuesClient + ctx := testAccProvider.Meta().(*ArmClient).StopContext + + for _, rs := range s.RootModule().Resources { + if rs.Type != "azurerm_servicebus_queue_authorization_rule" { + continue + } + + name := rs.Primary.Attributes["name"] + namespaceName := rs.Primary.Attributes["namespace_name"] + resourceGroup := rs.Primary.Attributes["resource_group_name"] + queueName := rs.Primary.Attributes["queue_name"] + + resp, err := conn.GetAuthorizationRule(ctx, resourceGroup, namespaceName, queueName, name) + if err != nil { + if !utils.ResponseWasNotFound(resp.Response) { + return err + } + } + } + + return nil +} + +func testCheckAzureRMServiceBusQueueAuthorizationRuleExists(name string) resource.TestCheckFunc { + return func(s *terraform.State) error { + rs, ok := s.RootModule().Resources[name] + if !ok { + return fmt.Errorf("Not found: %s", name) + } + + name := rs.Primary.Attributes["name"] + namespaceName := rs.Primary.Attributes["namespace_name"] + queueName := rs.Primary.Attributes["queue_name"] + resourceGroup, hasResourceGroup := rs.Primary.Attributes["resource_group_name"] + + if !hasResourceGroup { + return fmt.Errorf("Bad: no resource group found in state for ServiceBus Queue Authorization Rule: %s", name) + } + + conn := testAccProvider.Meta().(*ArmClient).serviceBusQueuesClient + ctx := testAccProvider.Meta().(*ArmClient).StopContext + + resp, err := conn.GetAuthorizationRule(ctx, resourceGroup, namespaceName, queueName, name) + if err != nil { + if utils.ResponseWasNotFound(resp.Response) { + return fmt.Errorf("Bad: ServiceBus Queue Authorization Rule %q (Queue %q / Namespace %q / Resource Group: %q) does not exist", name, queueName, namespaceName, resourceGroup) + } + + return fmt.Errorf("Bad: Get on ServiceBus Queue: %+v", err) + } + + return nil + } +} + +func testAccAzureRMServiceBusQueueAuthorizationRule_base(rInt int, location string, listen, send, manage bool) string { + return fmt.Sprintf(` +resource "azurerm_resource_group" "test" { + name = "acctestRG-%[1]d" + location = "%[2]s" +} + +resource "azurerm_servicebus_namespace" "test" { + name = "acctest-%[1]d" + location = "${azurerm_resource_group.test.location}" + resource_group_name = "${azurerm_resource_group.test.name}" + sku = "Standard" +} + +resource "azurerm_servicebus_queue" "test" { + name = "acctest-%[1]d" + resource_group_name = "${azurerm_resource_group.test.name}" + namespace_name = "${azurerm_servicebus_namespace.test.name}" + + enable_partitioning = true +} + +resource "azurerm_servicebus_queue_authorization_rule" "test" { + name = "acctest-%[1]d" + namespace_name = "${azurerm_servicebus_namespace.test.name}" + queue_name = "${azurerm_servicebus_queue.test.name}" + resource_group_name = "${azurerm_resource_group.test.name}" + + listen = %[3]t + send = %[4]t + manage = %[5]t +} +`, rInt, location, listen, send, manage) +} diff --git a/azurerm/resource_arm_servicebus_subscription.go b/azurerm/resource_arm_servicebus_subscription.go index 4fe4d7c52296..946ff34def52 100644 --- a/azurerm/resource_arm_servicebus_subscription.go +++ b/azurerm/resource_arm_servicebus_subscription.go @@ -22,9 +22,10 @@ func resourceArmServiceBusSubscription() *schema.Resource { Schema: map[string]*schema.Schema{ "name": { - Type: schema.TypeString, - Required: true, - ForceNew: true, + Type: schema.TypeString, + Required: true, + ForceNew: true, + ValidateFunc: azure.ValidateServiceBusSubscriptionName(), }, "namespace_name": { @@ -35,9 +36,10 @@ func resourceArmServiceBusSubscription() *schema.Resource { }, "topic_name": { - Type: schema.TypeString, - Required: true, - ForceNew: true, + Type: schema.TypeString, + Required: true, + ForceNew: true, + ValidateFunc: azure.ValidateServiceBusTopicName(), }, "location": deprecatedLocationSchema(), diff --git a/azurerm/resource_arm_servicebus_subscription_rule.go b/azurerm/resource_arm_servicebus_subscription_rule.go index f8f3f1e3c63b..fb413e1d8a37 100644 --- a/azurerm/resource_arm_servicebus_subscription_rule.go +++ b/azurerm/resource_arm_servicebus_subscription_rule.go @@ -40,15 +40,17 @@ func resourceArmServiceBusSubscriptionRule() *schema.Resource { }, "topic_name": { - Type: schema.TypeString, - Required: true, - ForceNew: true, + Type: schema.TypeString, + Required: true, + ForceNew: true, + ValidateFunc: azure.ValidateServiceBusTopicName(), }, "subscription_name": { - Type: schema.TypeString, - Required: true, - ForceNew: true, + Type: schema.TypeString, + Required: true, + ForceNew: true, + ValidateFunc: azure.ValidateServiceBusSubscriptionName(), }, "filter_type": { diff --git a/azurerm/resource_arm_servicebus_topic_authorization_rule.go b/azurerm/resource_arm_servicebus_topic_authorization_rule.go index 02d76767a2b0..388f8accbda4 100644 --- a/azurerm/resource_arm_servicebus_topic_authorization_rule.go +++ b/azurerm/resource_arm_servicebus_topic_authorization_rule.go @@ -22,7 +22,7 @@ func resourceArmServiceBusTopicAuthorizationRule() *schema.Resource { State: schema.ImportStatePassthrough, }, - Schema: map[string]*schema.Schema{ + Schema: azure.ServiceBusAuthorizationRuleSchemaFrom(map[string]*schema.Schema{ "name": { Type: schema.TypeString, Required: true, @@ -45,49 +45,7 @@ func resourceArmServiceBusTopicAuthorizationRule() *schema.Resource { }, "resource_group_name": resourceGroupNameSchema(), - - "listen": { - Type: schema.TypeBool, - Optional: true, - Default: false, - }, - - "send": { - Type: schema.TypeBool, - Optional: true, - Default: false, - }, - - "manage": { - Type: schema.TypeBool, - Optional: true, - Default: false, - }, - - "primary_key": { - Type: schema.TypeString, - Computed: true, - Sensitive: true, - }, - - "primary_connection_string": { - Type: schema.TypeString, - Computed: true, - Sensitive: true, - }, - - "secondary_key": { - Type: schema.TypeString, - Computed: true, - Sensitive: true, - }, - - "secondary_connection_string": { - Type: schema.TypeString, - Computed: true, - Sensitive: true, - }, - }, + }), CustomizeDiff: azure.ServiceBusAuthorizationRuleCustomizeDiff, } diff --git a/azurerm/resource_arm_servicebus_topic_authorization_rule_test.go b/azurerm/resource_arm_servicebus_topic_authorization_rule_test.go index 464731d5a30e..013b2b4870c1 100644 --- a/azurerm/resource_arm_servicebus_topic_authorization_rule_test.go +++ b/azurerm/resource_arm_servicebus_topic_authorization_rule_test.go @@ -2,6 +2,7 @@ package azurerm import ( "fmt" + "strconv" "testing" "github.com/hashicorp/terraform/helper/acctest" @@ -11,27 +12,23 @@ import ( ) func TestAccAzureRMServiceBusTopicAuthorizationRule_listen(t *testing.T) { - ri := acctest.RandInt() - config := testAccAzureRMServiceBusTopicAuthorizationRule_listen(ri, testLocation()) - - resource.Test(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - Providers: testAccProviders, - CheckDestroy: testCheckAzureRMServiceBusTopicAuthorizationRuleDestroy, - Steps: []resource.TestStep{ - { - Config: config, - Check: resource.ComposeTestCheckFunc( - testCheckAzureRMServiceBusTopicAuthorizationRuleExists("azurerm_servicebus_topic_authorization_rule.test"), - ), - }, - }, - }) + testAccAzureRMServiceBusTopicAuthorizationRule(t, true, false, false) } func TestAccAzureRMServiceBusTopicAuthorizationRule_send(t *testing.T) { - ri := acctest.RandInt() - config := testAccAzureRMServiceBusTopicAuthorizationRule_send(ri, testLocation()) + testAccAzureRMServiceBusTopicAuthorizationRule(t, false, true, false) +} + +func TestAccAzureRMServiceBusTopicAuthorizationRule_listensend(t *testing.T) { + testAccAzureRMServiceBusTopicAuthorizationRule(t, true, true, false) +} + +func TestAccAzureRMServiceBusTopicAuthorizationRule_manage(t *testing.T) { + testAccAzureRMServiceBusTopicAuthorizationRule(t, true, true, true) +} + +func testAccAzureRMServiceBusTopicAuthorizationRule(t *testing.T, listen, send, manage bool) { + resourceName := "azurerm_servicebus_topic_authorization_rule.test" resource.Test(t, resource.TestCase{ PreCheck: func() { testAccPreCheck(t) }, @@ -39,18 +36,31 @@ func TestAccAzureRMServiceBusTopicAuthorizationRule_send(t *testing.T) { CheckDestroy: testCheckAzureRMServiceBusTopicAuthorizationRuleDestroy, Steps: []resource.TestStep{ { - Config: config, + Config: testAccAzureRMServiceBusTopicAuthorizationRule_base(acctest.RandInt(), testLocation(), listen, send, manage), Check: resource.ComposeTestCheckFunc( - testCheckAzureRMServiceBusTopicAuthorizationRuleExists("azurerm_servicebus_topic_authorization_rule.test"), + testCheckAzureRMServiceBusTopicAuthorizationRuleExists(resourceName), + resource.TestCheckResourceAttrSet(resourceName, "name"), + resource.TestCheckResourceAttrSet(resourceName, "namespace_name"), + resource.TestCheckResourceAttrSet(resourceName, "primary_key"), + resource.TestCheckResourceAttrSet(resourceName, "secondary_key"), + resource.TestCheckResourceAttrSet(resourceName, "primary_connection_string"), + resource.TestCheckResourceAttrSet(resourceName, "secondary_connection_string"), + resource.TestCheckResourceAttr(resourceName, "listen", strconv.FormatBool(listen)), + resource.TestCheckResourceAttr(resourceName, "send", strconv.FormatBool(send)), + resource.TestCheckResourceAttr(resourceName, "manage", strconv.FormatBool(manage)), ), }, + { + ResourceName: resourceName, + ImportState: true, + ImportStateVerify: true, + }, }, }) } -func TestAccAzureRMServiceBusTopicAuthorizationRule_readwrite(t *testing.T) { - ri := acctest.RandInt() - config := testAccAzureRMServiceBusTopicAuthorizationRule_readWrite(ri, testLocation()) +func TestAccAzureRMServiceBusTopicAuthorizationRule_rightsUpdate(t *testing.T) { + resourceName := "azurerm_servicebus_topic_authorization_rule.test" resource.Test(t, resource.TestCase{ PreCheck: func() { testAccPreCheck(t) }, @@ -58,30 +68,34 @@ func TestAccAzureRMServiceBusTopicAuthorizationRule_readwrite(t *testing.T) { CheckDestroy: testCheckAzureRMServiceBusTopicAuthorizationRuleDestroy, Steps: []resource.TestStep{ { - Config: config, + Config: testAccAzureRMServiceBusTopicAuthorizationRule_base(acctest.RandInt(), testLocation(), true, false, false), Check: resource.ComposeTestCheckFunc( - testCheckAzureRMServiceBusTopicAuthorizationRuleExists("azurerm_servicebus_topic_authorization_rule.test"), + testCheckAzureRMServiceBusTopicAuthorizationRuleExists(resourceName), + resource.TestCheckResourceAttr(resourceName, "listen", "true"), + resource.TestCheckResourceAttr(resourceName, "send", "false"), + resource.TestCheckResourceAttr(resourceName, "manage", "false"), ), }, - }, - }) -} - -func TestAccAzureRMServiceBusTopicAuthorizationRule_manage(t *testing.T) { - ri := acctest.RandInt() - config := testAccAzureRMServiceBusTopicAuthorizationRule_manage(ri, testLocation()) - - resource.Test(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - Providers: testAccProviders, - CheckDestroy: testCheckAzureRMServiceBusTopicAuthorizationRuleDestroy, - Steps: []resource.TestStep{ { - Config: config, + Config: testAccAzureRMServiceBusTopicAuthorizationRule_base(acctest.RandInt(), testLocation(), true, true, true), Check: resource.ComposeTestCheckFunc( - testCheckAzureRMServiceBusTopicAuthorizationRuleExists("azurerm_servicebus_topic_authorization_rule.test"), + testCheckAzureRMServiceBusTopicAuthorizationRuleExists(resourceName), + resource.TestCheckResourceAttrSet(resourceName, "name"), + resource.TestCheckResourceAttrSet(resourceName, "namespace_name"), + resource.TestCheckResourceAttrSet(resourceName, "primary_key"), + resource.TestCheckResourceAttrSet(resourceName, "secondary_key"), + resource.TestCheckResourceAttrSet(resourceName, "primary_connection_string"), + resource.TestCheckResourceAttrSet(resourceName, "secondary_connection_string"), + resource.TestCheckResourceAttr(resourceName, "listen", "true"), + resource.TestCheckResourceAttr(resourceName, "send", "true"), + resource.TestCheckResourceAttr(resourceName, "manage", "true"), ), }, + { + ResourceName: resourceName, + ImportState: true, + ImportStateVerify: true, + }, }, }) } @@ -142,130 +156,35 @@ func testCheckAzureRMServiceBusTopicAuthorizationRuleExists(name string) resourc } } -func testAccAzureRMServiceBusTopicAuthorizationRule_listen(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}" -} - -resource "azurerm_servicebus_topic_authorization_rule" "test" { - name = "acctestservicebustopicrule-%d" - namespace_name = "${azurerm_servicebus_namespace.test.name}" - topic_name = "${azurerm_servicebus_topic.test.name}" - resource_group_name = "${azurerm_resource_group.test.name}" - listen = true - send = false - manage = false -} -`, rInt, location, rInt, rInt, rInt) -} - -func testAccAzureRMServiceBusTopicAuthorizationRule_send(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}" -} - -resource "azurerm_servicebus_topic_authorization_rule" "test" { - name = "acctestservicebustopicrule-%d" - namespace_name = "${azurerm_servicebus_namespace.test.name}" - topic_name = "${azurerm_servicebus_topic.test.name}" - resource_group_name = "${azurerm_resource_group.test.name}" - listen = false - send = true - manage = false -} -`, rInt, location, rInt, rInt, rInt) -} - -func testAccAzureRMServiceBusTopicAuthorizationRule_readWrite(rInt int, location string) string { +func testAccAzureRMServiceBusTopicAuthorizationRule_base(rInt int, location string, listen, send, manage bool) string { return fmt.Sprintf(` resource "azurerm_resource_group" "test" { - name = "acctestRG-%d" - location = "%s" + name = "acctestRG-%[1]d" + location = "%[2]s" } resource "azurerm_servicebus_namespace" "test" { - name = "acctestservicebusnamespace-%d" + name = "acctest-%[1]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" + name = "acctestservicebustopic-%[1]d" namespace_name = "${azurerm_servicebus_namespace.test.name}" resource_group_name = "${azurerm_resource_group.test.name}" } resource "azurerm_servicebus_topic_authorization_rule" "test" { - name = "acctestservicebustopicrule-%d" - namespace_name = "${azurerm_servicebus_namespace.test.name}" - topic_name = "${azurerm_servicebus_topic.test.name}" - resource_group_name = "${azurerm_resource_group.test.name}" - listen = true - send = true - manage = false -} -`, rInt, location, rInt, rInt, rInt) -} - -func testAccAzureRMServiceBusTopicAuthorizationRule_manage(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" + name = "acctest-%[1]d" namespace_name = "${azurerm_servicebus_namespace.test.name}" resource_group_name = "${azurerm_resource_group.test.name}" -} + topic_name = "${azurerm_servicebus_topic.test.name}" -resource "azurerm_servicebus_topic_authorization_rule" "test" { - name = "acctestservicebustopicrule-%d" - namespace_name = "${azurerm_servicebus_namespace.test.name}" - topic_name = "${azurerm_servicebus_topic.test.name}" - resource_group_name = "${azurerm_resource_group.test.name}" - listen = true - send = true - manage = true + listen = %[3]t + send = %[4]t + manage = %[5]t } -`, rInt, location, rInt, rInt, rInt) +`, rInt, location, listen, send, manage) } diff --git a/examples/servicebus/main.tf b/examples/servicebus/main.tf index 3bfbadc3ab91..1f17fe2f71ec 100644 --- a/examples/servicebus/main.tf +++ b/examples/servicebus/main.tf @@ -1,4 +1,4 @@ -resource "azurerm_resource_group" "rg" { +resource "azurerm_resource_group" "example" { name = "${var.resource_group}" location = "${var.location}" } @@ -10,29 +10,43 @@ resource "random_integer" "ri" { resource "azurerm_servicebus_namespace" "example" { name = "tfex-servicebus${random_integer.ri.result}" - location = "${var.location}" - resource_group_name = "${var.resource_group}" + location = "${azurerm_resource_group.example.location}" + resource_group_name = "${azurerm_resource_group.example.name}" sku = "standard" } resource "azurerm_servicebus_namespace_authorization_rule" "example" { name = "tfex_servicebus${random_integer.ri.result}_authrule" namespace_name = "${azurerm_servicebus_namespace.example.name}" - resource_group_name = "${var.resource_group}" + resource_group_name = "${azurerm_resource_group.example.name}" + + send = true + listen = true manage = true } resource "azurerm_servicebus_topic" "source" { name = "tfex_servicebus${random_integer.ri.result}_topic" - resource_group_name = "${var.resource_group}" + resource_group_name = "${azurerm_resource_group.example.name}" namespace_name = "${azurerm_servicebus_namespace.example.name}" enable_partitioning = true } +resource "azurerm_servicebus_topic_authorization_rule" "example" { + name = "tfex_servicebus${random_integer.ri.result}_authrule" + namespace_name = "${azurerm_servicebus_namespace.example.name}" + topic_name = "${azurerm_servicebus_topic.source.name}" + resource_group_name = "${azurerm_resource_group.example.name}" + + send = true + listen = true + manage = true +} + resource "azurerm_servicebus_topic" "forward_to" { name = "tfex_servicebus${random_integer.ri.result}_forwardto" - resource_group_name = "${var.resource_group}" + resource_group_name = "${azurerm_resource_group.example.name}" namespace_name = "${azurerm_servicebus_namespace.example.name}" enable_partitioning = true @@ -40,10 +54,27 @@ resource "azurerm_servicebus_topic" "forward_to" { resource "azurerm_servicebus_subscription" "example" { name = "tfex_servicebus${random_integer.ri.result}_subscription" - resource_group_name = "${var.resource_group}" + resource_group_name = "${azurerm_resource_group.example.name}" namespace_name = "${azurerm_servicebus_namespace.example.name}" topic_name = "${azurerm_servicebus_topic.source.name}" forward_to = "${azurerm_servicebus_topic.forward_to.name}" max_delivery_count = 1 } +resource "azurerm_servicebus_queue" "example" { + name = "tfex_servicebus_queue" + resource_group_name = "${azurerm_resource_group.example.name}" + namespace_name = "${azurerm_servicebus_namespace.example.name}" + + enable_partitioning = true +} + +resource "azurerm_servicebus_queue_authorization_rule" "example" { + name = "tfex_servicebus${random_integer.ri.result}_authrule" + namespace_name = "${azurerm_servicebus_namespace.example.name}" + queue_name = "${azurerm_servicebus_queue.example.name}" + resource_group_name = "${azurerm_resource_group.example.name}" + + send = true + listen = true +} \ No newline at end of file diff --git a/website/azurerm.erb b/website/azurerm.erb index 1a68078a90e5..59502fbd037a 100644 --- a/website/azurerm.erb +++ b/website/azurerm.erb @@ -588,7 +588,11 @@ > azurerm_servicebus_queue - + + + > + azurerm_servicebus_queue_authorization_rule + > azurerm_servicebus_subscription diff --git a/website/docs/r/servicebus_queue_authorization_rule.html.markdown b/website/docs/r/servicebus_queue_authorization_rule.html.markdown new file mode 100644 index 000000000000..de62bb11621d --- /dev/null +++ b/website/docs/r/servicebus_queue_authorization_rule.html.markdown @@ -0,0 +1,94 @@ + +--- +layout: "azurerm" +page_title: "Azure Resource Manager: azurerm_servicebus_queue_authorization_rule" +sidebar_current: "docs-azurerm-resource-servicebus-queue-authorization-rule" +description: |- + Manages an Authorization Rule for a ServiceBus Queue. +--- + +# azurerm_servicebus_queue_authorization_rule + +Manages an Authorization Rule for a ServiceBus Queue. + +## Example Usage + +```hcl +resource "azurerm_resource_group" "example" { + name = "terraform-servicebus" + location = "West US" +} + +resource "azurerm_servicebus_namespace" "example" { + name = "tfex_sevicebus_namespace" + location = "${azurerm_resource_group.example.location}" + resource_group_name = "${azurerm_resource_group.example.name}" + sku = "standard" + + tags { + source = "terraform" + } +} + +resource "azurerm_servicebus_queue" "example" { + name = "acctest-%[1]d" + resource_group_name = "${azurerm_resource_group.test.name}" + namespace_name = "${azurerm_servicebus_namespace.test.name}" + + enable_partitioning = true +} + +resource "azurerm_servicebus_queue_authorization_rule" "example" { + name = "examplerule" + namespace_name = "${azurerm_servicebus_namespace.example.name}" + queue_name = "${azurerm_servicebus_queue.example.name}" + resource_group_name = "${azurerm_resource_group.example.name}" + + listen = true + send = true + manage = false +} +``` + +## Argument Reference + +The following arguments are supported: + +* `name` - (Required) Specifies the name of the Authorization Rule. Changing this forces a new resource to be created. + +* `namespace_name` - (Required) Specifies the name of the ServiceBus Namespace in which the Queue exists. Changing this forces a new resource to be created. + +* `queue_name` - (Required) Specifies the name of the ServiceBus Queue. Changing this forces a new resource to be created. + +* `resource_group_name` - (Required) The name of the Resource Group in which the ServiceBus Namespace exists. Changing this forces a new resource to be created. + +~> **NOTE** At least one of the 3 permissions below needs to be set. + +* `listen` - (Optional) Does this Authorization Rule have Listen permissions to the ServiceBus Queue? Defaults to `false`. + +* `send` - (Optional) Does this Authorization Rule have Send permissions to the ServiceBus Queue? Defaults to `false`. + +* `manage` - (Optional) Does this Authorization Rule have Manage permissions to the ServiceBus Queue? When this property is `true` - both `listen` and `send` must be too. Defaults to `false`. + +## Attributes Reference + +The following attributes are exported: + +* `id` - The ID of the Authorization Rule. + +* `primary_key` - The Primary Key for the Authorization Rule. + +* `primary_connection_string` - The Primary Connection String for the Authorization Rule. + +* `secondary_key` - The Secondary Key for the Authorization Rule. + +* `secondary_connection_string` - The Secondary Connection String for the Authorization Rule. + +## Import + +ServiceBus Queue Authorization Rules can be imported using the `resource id`, e.g. + +```shell +terraform import azurerm_servicebus_queue_authorization_rule.rule1 /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/group1/providers/Microsoft.ServiceBus/namespaces/namespace1/queues/queue1/authorizationRules/rule1 +``` +``