Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

azurerm_bot_service_azure_bot - support for local_authentication_enabled #23096

Merged
merged 3 commits into from
Sep 5, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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