Skip to content

Commit

Permalink
azurerm_bot_service_azure_bot - support for `local_authentication_e…
Browse files Browse the repository at this point in the history
…nabled` (#23096)

* azurerm_bot_service_azure_bot - support for

* update code

* update code
  • Loading branch information
neil-yechenwei authored Sep 5, 2023
1 parent 8db895b commit 481240e
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 5 deletions.
11 changes: 6 additions & 5 deletions internal/services/bot/bot_service_azure_bot_resource_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
17 changes: 17 additions & 0 deletions internal/services/bot/bot_service_resource_base.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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)),
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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{}))
}
Expand Down
2 changes: 2 additions & 0 deletions website/docs/r/bot_service_azure_bot.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down

0 comments on commit 481240e

Please sign in to comment.