Skip to content

Commit

Permalink
azurerm_bot_service_azure_bot - send value for `developer_app_insig…
Browse files Browse the repository at this point in the history
…hts_api_key` (#27280)
  • Loading branch information
stephybun authored Sep 5, 2024
1 parent 50ebbfd commit 3714f08
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 12 deletions.
4 changes: 2 additions & 2 deletions internal/services/bot/bot_service_azure_bot_resource_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,14 +47,14 @@ func TestAccBotServiceAzureBot_completeUpdate(t *testing.T) {
check.That(data.ResourceName).ExistsInAzure(r),
),
},
data.ImportStep(),
data.ImportStep("developer_app_insights_api_key"),
{
Config: r.update(data),
Check: acceptance.ComposeTestCheckFunc(
check.That(data.ResourceName).ExistsInAzure(r),
),
},
data.ImportStep(),
data.ImportStep("developer_app_insights_api_key"),
})
}

Expand Down
15 changes: 5 additions & 10 deletions internal/services/bot/bot_service_resource_base.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,10 +72,6 @@ func (br botBaseResource) arguments(fields map[string]*pluginsdk.Schema) map[str
Optional: true,
Sensitive: true,
ValidateFunc: validation.StringIsNotEmpty,
DiffSuppressFunc: func(k, old, new string, d *pluginsdk.ResourceData) bool {
// This field for the api key isn't returned at all from Azure
return (new == d.Get(k).(string)) && (old == "")
},
},

"developer_app_insights_application_id": {
Expand Down Expand Up @@ -357,6 +353,11 @@ func (br botBaseResource) readFunc() sdk.ResourceFunc {

metadata.ResourceData.Set("tags", tags.ToTypedObject(resp.Tags))

// The API doesn't return this property, so we need to set the value from config into state
if apiKey, ok := metadata.ResourceData.GetOk("developer_app_insights_api_key"); ok && apiKey.(string) != "" {
metadata.ResourceData.Set("developer_app_insights_api_key", apiKey.(string))
}

if props := resp.Properties; props != nil {
msAppId := ""
if v := props.MsaAppID; v != nil {
Expand All @@ -382,12 +383,6 @@ func (br botBaseResource) readFunc() sdk.ResourceFunc {
}
metadata.ResourceData.Set("developer_app_insights_key", key)

apiKey := ""
if v := props.DeveloperAppInsightsAPIKey; v != nil {
apiKey = *v
}
metadata.ResourceData.Set("developer_app_insights_api_key", apiKey)

appInsightsId := ""
if v := props.DeveloperAppInsightsApplicationID; v != nil {
appInsightsId = *v
Expand Down

0 comments on commit 3714f08

Please sign in to comment.