diff --git a/internal/services/bot/bot_connection_resource.go b/internal/services/bot/bot_connection_resource.go index d82fa2e46e1d..f02fce0a547a 100644 --- a/internal/services/bot/bot_connection_resource.go +++ b/internal/services/bot/bot_connection_resource.go @@ -12,8 +12,8 @@ import ( "github.com/hashicorp/terraform-provider-azurerm/helpers/azure" "github.com/hashicorp/terraform-provider-azurerm/helpers/tf" "github.com/hashicorp/terraform-provider-azurerm/internal/clients" + "github.com/hashicorp/terraform-provider-azurerm/internal/features" "github.com/hashicorp/terraform-provider-azurerm/internal/services/bot/parse" - "github.com/hashicorp/terraform-provider-azurerm/internal/tags" "github.com/hashicorp/terraform-provider-azurerm/internal/tf/pluginsdk" "github.com/hashicorp/terraform-provider-azurerm/internal/tf/validation" "github.com/hashicorp/terraform-provider-azurerm/internal/timeouts" @@ -21,7 +21,7 @@ import ( ) func resourceArmBotConnection() *pluginsdk.Resource { - return &pluginsdk.Resource{ + resource := &pluginsdk.Resource{ Create: resourceArmBotConnectionCreate, Read: resourceArmBotConnectionRead, Update: resourceArmBotConnectionUpdate, @@ -90,10 +90,21 @@ func resourceArmBotConnection() *pluginsdk.Resource { Type: pluginsdk.TypeString, }, }, - - "tags": tags.Schema(), }, } + + if !features.FourPointOhBeta() { + resource.Schema["tags"] = &pluginsdk.Schema{ + Type: pluginsdk.TypeMap, + Optional: true, + Elem: &pluginsdk.Schema{ + Type: pluginsdk.TypeString, + }, + Deprecated: "This property has been deprecated as the API no longer supports tags and will be removed in version 4.0 of the provider.", + } + } + + return resource } func resourceArmBotConnectionCreate(d *pluginsdk.ResourceData, meta interface{}) error { @@ -152,7 +163,6 @@ func resourceArmBotConnectionCreate(d *pluginsdk.ResourceData, meta interface{}) }, Kind: botservice.KindBot, Location: utils.String(d.Get("location").(string)), - Tags: tags.Expand(d.Get("tags").(map[string]interface{})), } if v, ok := d.GetOk("parameters"); ok { @@ -201,7 +211,7 @@ func resourceArmBotConnectionRead(d *pluginsdk.ResourceData, meta interface{}) e } } - return tags.FlattenAndSet(d, resp.Tags) + return nil } func resourceArmBotConnectionUpdate(d *pluginsdk.ResourceData, meta interface{}) error { @@ -223,7 +233,6 @@ func resourceArmBotConnectionUpdate(d *pluginsdk.ResourceData, meta interface{}) }, Kind: botservice.KindBot, Location: utils.String(d.Get("location").(string)), - Tags: tags.Expand(d.Get("tags").(map[string]interface{})), } if v, ok := d.GetOk("parameters"); ok { diff --git a/internal/services/bot/bot_connection_resource_test.go b/internal/services/bot/bot_connection_resource_test.go index f64e868141a4..31510d4245eb 100644 --- a/internal/services/bot/bot_connection_resource_test.go +++ b/internal/services/bot/bot_connection_resource_test.go @@ -66,7 +66,7 @@ func (t BotConnectionResource) Exists(ctx context.Context, clients *clients.Clie return utils.Bool(resp.Properties != nil), nil } -func (BotConnectionResource) basicConfig(data acceptance.TestData) string { +func (r BotConnectionResource) basicConfig(data acceptance.TestData) string { return fmt.Sprintf(` %s @@ -76,13 +76,13 @@ resource "azurerm_bot_connection" "test" { location = azurerm_bot_channels_registration.test.location resource_group_name = azurerm_resource_group.test.name service_provider_name = "box" - client_id = "test" - client_secret = "secret" + client_id = data.azurerm_client_config.current.client_id + client_secret = "86546868-e7ed-429f-b0e5-3a1caea7db64" } -`, BotChannelsRegistrationResource{}.basicConfig(data), data.RandomInteger) +`, r.template(data), data.RandomInteger) } -func (BotConnectionResource) completeConfig(data acceptance.TestData) string { +func (r BotConnectionResource) completeConfig(data acceptance.TestData) string { return fmt.Sprintf(` %s @@ -92,34 +92,64 @@ resource "azurerm_bot_connection" "test" { location = azurerm_bot_channels_registration.test.location resource_group_name = azurerm_resource_group.test.name service_provider_name = "Salesforce" - client_id = "test" - client_secret = "secret" - scopes = "testscope" + client_id = data.azurerm_client_config.current.client_id + client_secret = "60a97b1d-0894-4c5a-9968-7d1d29d77aed" + scopes = "/subscriptions/${data.azurerm_client_config.current.subscription_id}" parameters = { - loginUri = "www.example.com" + loginUri = "https://www.google.com" } } -`, BotChannelsRegistrationResource{}.basicConfig(data), data.RandomInteger) +`, r.template(data), data.RandomInteger) } -func (BotConnectionResource) completeUpdateConfig(data acceptance.TestData) string { +func (r BotConnectionResource) completeUpdateConfig(data acceptance.TestData) string { return fmt.Sprintf(` %s +resource "azurerm_user_assigned_identity" "test" { + name = "acctestUAI-%d" + location = azurerm_resource_group.test.location + resource_group_name = azurerm_resource_group.test.name +} + resource "azurerm_bot_connection" "test" { name = "acctestBc%d" bot_name = azurerm_bot_channels_registration.test.name location = azurerm_bot_channels_registration.test.location resource_group_name = azurerm_resource_group.test.name service_provider_name = "Salesforce" - client_id = "test2" - client_secret = "secret2" - scopes = "testscope2" + client_id = azurerm_user_assigned_identity.test.client_id + client_secret = "32ea21cb-cb20-4df9-ad39-b55e985e9117" + scopes = "/subscriptions/${data.azurerm_client_config.current.subscription_id}/resourceGroups/${azurerm_resource_group.test.name}" parameters = { - loginUri = "www.example2.com" + loginUri = "https://www.terraform.io" } } -`, BotChannelsRegistrationResource{}.basicConfig(data), data.RandomInteger) +`, r.template(data), data.RandomInteger, data.RandomInteger) +} + +func (r BotConnectionResource) template(data acceptance.TestData) string { + return fmt.Sprintf(` +provider "azurerm" { + features {} +} + +data "azurerm_client_config" "current" { +} + +resource "azurerm_resource_group" "test" { + name = "acctestRG-%d" + location = "%s" +} + +resource "azurerm_bot_channels_registration" "test" { + name = "acctestdf%d" + location = "global" + resource_group_name = azurerm_resource_group.test.name + sku = "F0" + microsoft_app_id = data.azurerm_client_config.current.client_id +} +`, data.RandomInteger, data.Locations.Primary, data.RandomInteger) } diff --git a/website/docs/r/bot_connection.html.markdown b/website/docs/r/bot_connection.html.markdown index 043e75d91f56..3b62f6d949c1 100644 --- a/website/docs/r/bot_connection.html.markdown +++ b/website/docs/r/bot_connection.html.markdown @@ -63,6 +63,7 @@ The following arguments are supported: * `tags` - (Optional) A mapping of tags to assign to the resource. +-> **Note:** `tags` has been deprecated as the API no longer supports it and will be removed in version 4.0 of the provider. ## Attributes Reference