From afb016de771f72b649f35cc926722b73272a9a4d Mon Sep 17 00:00:00 2001 From: Catriona Date: Wed, 6 Apr 2022 12:18:17 +0100 Subject: [PATCH] add support for local_auth_enabled --- .../servicebus/servicebus_namespace_resource.go | 16 ++++++++++++++-- .../servicebus_namespace_resource_test.go | 1 + .../docs/r/servicebus_namespace.html.markdown | 2 ++ 3 files changed, 17 insertions(+), 2 deletions(-) diff --git a/internal/services/servicebus/servicebus_namespace_resource.go b/internal/services/servicebus/servicebus_namespace_resource.go index e36558fcddfe..04ec2fdfb845 100644 --- a/internal/services/servicebus/servicebus_namespace_resource.go +++ b/internal/services/servicebus/servicebus_namespace_resource.go @@ -121,6 +121,12 @@ func resourceServiceBusNamespace() *pluginsdk.Resource { }, }, + "local_auth_enabled": { + Type: pluginsdk.TypeBool, + Optional: true, + Default: true, + }, + "default_primary_connection_string": { Type: pluginsdk.TypeString, Computed: true, @@ -203,8 +209,9 @@ func resourceServiceBusNamespaceCreateUpdate(d *pluginsdk.ResourceData, meta int Tier: servicebus.SkuTier(sku), }, SBNamespaceProperties: &servicebus.SBNamespaceProperties{ - ZoneRedundant: utils.Bool(d.Get("zone_redundant").(bool)), - Encryption: expandServiceBusNamespaceEncryption(d.Get("customer_managed_key").([]interface{})), + ZoneRedundant: utils.Bool(d.Get("zone_redundant").(bool)), + Encryption: expandServiceBusNamespaceEncryption(d.Get("customer_managed_key").([]interface{})), + DisableLocalAuth: utils.Bool(!d.Get("local_auth_enabled").(bool)), }, Tags: tags.Expand(t), } @@ -281,6 +288,11 @@ func resourceServiceBusNamespaceRead(d *pluginsdk.ResourceData, meta interface{} if customerManagedKey, err := flattenServiceBusNamespaceEncryption(properties.Encryption); err == nil { d.Set("customer_managed_key", customerManagedKey) } + localAuthEnabled := true + if properties.DisableLocalAuth != nil { + localAuthEnabled = !*properties.DisableLocalAuth + } + d.Set("local_auth_enabled", localAuthEnabled) } keys, err := clientStable.ListKeys(ctx, id.ResourceGroup, id.Name, serviceBusNamespaceDefaultAuthorizationRule) diff --git a/internal/services/servicebus/servicebus_namespace_resource_test.go b/internal/services/servicebus/servicebus_namespace_resource_test.go index a4316ba40b30..c1aa42a3c401 100644 --- a/internal/services/servicebus/servicebus_namespace_resource_test.go +++ b/internal/services/servicebus/servicebus_namespace_resource_test.go @@ -236,6 +236,7 @@ resource "azurerm_servicebus_namespace" "test" { location = azurerm_resource_group.test.location resource_group_name = azurerm_resource_group.test.name sku = "Basic" + local_auth_enabled = false tags = { ENV = "Test" } diff --git a/website/docs/r/servicebus_namespace.html.markdown b/website/docs/r/servicebus_namespace.html.markdown index c6e0ef34917b..d2ec109dba14 100644 --- a/website/docs/r/servicebus_namespace.html.markdown +++ b/website/docs/r/servicebus_namespace.html.markdown @@ -54,6 +54,8 @@ The following arguments are supported: * `customer_managed_key` - (Optional) An `customer_managed_key` block as defined below. +* `local_auth_enabled` - (Optional) Whether or not SAS authentication is enabled for the Service Bus namespace. Defaults to `true`. + * `zone_redundant` - (Optional) Whether or not this resource is zone redundant. `sku` needs to be `Premium`. Defaults to `false`. * `tags` - (Optional) A mapping of tags to assign to the resource.