From 481240ef6a729f08c03b6beb9773a1663bd3911f Mon Sep 17 00:00:00 2001 From: Neil Ye Date: Tue, 5 Sep 2023 15:41:24 +0800 Subject: [PATCH] `azurerm_bot_service_azure_bot` - support for `local_authentication_enabled` (#23096) * azurerm_bot_service_azure_bot - support for * update code * update code --- .../bot/bot_service_azure_bot_resource_test.go | 11 ++++++----- .../services/bot/bot_service_resource_base.go | 17 +++++++++++++++++ .../docs/r/bot_service_azure_bot.html.markdown | 2 ++ 3 files changed, 25 insertions(+), 5 deletions(-) diff --git a/internal/services/bot/bot_service_azure_bot_resource_test.go b/internal/services/bot/bot_service_azure_bot_resource_test.go index 23d66b22dd00..3a03ed63003b 100644 --- a/internal/services/bot/bot_service_azure_bot_resource_test.go +++ b/internal/services/bot/bot_service_azure_bot_resource_test.go @@ -183,11 +183,12 @@ resource "azurerm_application_insights_api_key" "test" { } resource "azurerm_bot_service_azure_bot" "test" { - name = "acctestdf%[1]d" - resource_group_name = azurerm_resource_group.test.name - location = "global" - microsoft_app_id = data.azurerm_client_config.current.client_id - sku = "F0" + name = "acctestdf%[1]d" + resource_group_name = azurerm_resource_group.test.name + location = "global" + microsoft_app_id = data.azurerm_client_config.current.client_id + sku = "F0" + local_authentication_enabled = false endpoint = "https://example.com" developer_app_insights_api_key = azurerm_application_insights_api_key.test.api_key diff --git a/internal/services/bot/bot_service_resource_base.go b/internal/services/bot/bot_service_resource_base.go index 9f24a669716e..b1bc2fdc890f 100644 --- a/internal/services/bot/bot_service_resource_base.go +++ b/internal/services/bot/bot_service_resource_base.go @@ -107,6 +107,12 @@ func (br botBaseResource) arguments(fields map[string]*pluginsdk.Schema) map[str }, false), }, + "local_authentication_enabled": { + Type: pluginsdk.TypeBool, + Optional: true, + Default: true, + }, + "luis_app_ids": { Type: pluginsdk.TypeList, Optional: true, @@ -180,6 +186,7 @@ func (br botBaseResource) createFunc(resourceName, botKind string) sdk.ResourceF DeveloperAppInsightKey: utils.String(metadata.ResourceData.Get("developer_app_insights_key").(string)), DeveloperAppInsightsAPIKey: utils.String(metadata.ResourceData.Get("developer_app_insights_api_key").(string)), DeveloperAppInsightsApplicationID: utils.String(metadata.ResourceData.Get("developer_app_insights_application_id").(string)), + DisableLocalAuth: utils.Bool(!metadata.ResourceData.Get("local_authentication_enabled").(bool)), LuisAppIds: utils.ExpandStringSlice(metadata.ResourceData.Get("luis_app_ids").([]interface{})), LuisKey: utils.String(metadata.ResourceData.Get("luis_key").(string)), IsStreamingSupported: utils.Bool(metadata.ResourceData.Get("streaming_endpoint_enabled").(bool)), @@ -295,6 +302,12 @@ func (br botBaseResource) readFunc() sdk.ResourceFunc { } metadata.ResourceData.Set("microsoft_app_msi_id", msaAppMSIId) + localAuthEnabled := true + if v := props.DisableLocalAuth; v != nil { + localAuthEnabled = !*v + } + metadata.ResourceData.Set("local_authentication_enabled", localAuthEnabled) + var luisAppIds []string if v := props.LuisAppIds; v != nil { luisAppIds = *v @@ -367,6 +380,10 @@ func (br botBaseResource) updateFunc() sdk.ResourceFunc { existing.Properties.DeveloperAppInsightsApplicationID = utils.String(metadata.ResourceData.Get("developer_app_insights_application_id").(string)) } + if metadata.ResourceData.HasChange("local_authentication_enabled") { + existing.Properties.DisableLocalAuth = utils.Bool(!metadata.ResourceData.Get("local_authentication_enabled").(bool)) + } + if metadata.ResourceData.HasChange("luis_app_ids") { existing.Properties.LuisAppIds = utils.ExpandStringSlice(metadata.ResourceData.Get("luis_app_ids").([]interface{})) } diff --git a/website/docs/r/bot_service_azure_bot.html.markdown b/website/docs/r/bot_service_azure_bot.html.markdown index c0306afdb11b..a68870375dd1 100644 --- a/website/docs/r/bot_service_azure_bot.html.markdown +++ b/website/docs/r/bot_service_azure_bot.html.markdown @@ -80,6 +80,8 @@ The following arguments are supported: * `microsoft_app_type` - (Optional) The Microsoft App Type for this Azure Bot Service. Possible values are `MultiTenant`, `SingleTenant` and `UserAssignedMSI`. Changing this forces a new resource to be created. +* `local_authentication_enabled` - (Optional) Is local authentication enabled? Defaults to `true`. + * `luis_app_ids` - (Optional) A list of LUIS App IDs to associate with this Azure Bot Service. * `luis_key` - (Optional) The LUIS key to associate with this Azure Bot Service.