From 9dc4b66b66bd1eb5b834c6dfc96a983b67938c13 Mon Sep 17 00:00:00 2001 From: Wyatt Fry Date: Thu, 16 Jan 2025 11:30:05 -0500 Subject: [PATCH 01/28] Resolve 4.0 TODOs Kusto --- .../kusto/kusto_attached_database_configuration_resource.go | 3 +-- .../kusto/kusto_eventgrid_data_connection_resource.go | 6 ++---- 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/internal/services/kusto/kusto_attached_database_configuration_resource.go b/internal/services/kusto/kusto_attached_database_configuration_resource.go index f562a97af5f1..ed80c608ba12 100644 --- a/internal/services/kusto/kusto_attached_database_configuration_resource.go +++ b/internal/services/kusto/kusto_attached_database_configuration_resource.go @@ -73,8 +73,7 @@ func resourceKustoAttachedDatabaseConfiguration() *pluginsdk.Resource { ValidateFunc: validation.Any(validate.DatabaseName, validation.StringInSlice([]string{"*"}, false)), }, - // TODO: this should become `cluster_id` in 4.0 - "cluster_resource_id": { + "cluster_id": { Type: pluginsdk.TypeString, Required: true, ForceNew: true, diff --git a/internal/services/kusto/kusto_eventgrid_data_connection_resource.go b/internal/services/kusto/kusto_eventgrid_data_connection_resource.go index 5361aceb5db2..2334b4baf7ca 100644 --- a/internal/services/kusto/kusto_eventgrid_data_connection_resource.go +++ b/internal/services/kusto/kusto_eventgrid_data_connection_resource.go @@ -138,15 +138,13 @@ func resourceKustoEventGridDataConnection() *pluginsdk.Resource { ValidateFunc: validation.StringInSlice(dataconnections.PossibleValuesForDatabaseRouting(), false), }, - // TODO: rename this to `eventgrid_event_subscription_id` in 4.0 - "eventgrid_resource_id": { + "eventgrid_event_subscription_id": { Type: pluginsdk.TypeString, Optional: true, ValidateFunc: eventsubscriptions.ValidateScopedEventSubscriptionID, }, - // TODO: rename this to `managed_identity_id` in 4.0 - "managed_identity_resource_id": { + "managed_identity_id": { Type: pluginsdk.TypeString, Optional: true, ValidateFunc: validation.Any( From b2790d3638a8db513e0fc8f875f63b941445c693 Mon Sep 17 00:00:00 2001 From: Wyatt Fry Date: Mon, 27 Jan 2025 14:13:54 -0500 Subject: [PATCH 02/28] proper deprecation --- ...ttached_database_configuration_resource.go | 17 ++++++++++- ...usto_eventgrid_data_connection_resource.go | 28 ++++++++++++++++++- 2 files changed, 43 insertions(+), 2 deletions(-) diff --git a/internal/services/kusto/kusto_attached_database_configuration_resource.go b/internal/services/kusto/kusto_attached_database_configuration_resource.go index ed80c608ba12..0507e0052ae1 100644 --- a/internal/services/kusto/kusto_attached_database_configuration_resource.go +++ b/internal/services/kusto/kusto_attached_database_configuration_resource.go @@ -5,6 +5,7 @@ package kusto import ( "fmt" + "github.com/hashicorp/terraform-provider-azurerm/internal/features" "time" "github.com/hashicorp/go-azure-helpers/lang/response" @@ -24,7 +25,7 @@ import ( ) func resourceKustoAttachedDatabaseConfiguration() *pluginsdk.Resource { - return &pluginsdk.Resource{ + resource := &pluginsdk.Resource{ Create: resourceKustoAttachedDatabaseConfigurationCreateUpdate, Read: resourceKustoAttachedDatabaseConfigurationRead, Update: resourceKustoAttachedDatabaseConfigurationCreateUpdate, @@ -153,6 +154,20 @@ func resourceKustoAttachedDatabaseConfiguration() *pluginsdk.Resource { }, }, } + + if !features.FivePointOhBeta() { + resource.Schema["cluster_resource_id"] = &pluginsdk.Schema{ + Type: pluginsdk.TypeString, + Required: true, + ForceNew: true, + ValidateFunc: commonids.ValidateKustoClusterID, + Deprecated: "Use `cluster_id` instead.", + } + resource.Schema["cluster_id"].ConflictsWith = []string{"cluster_resource_id"} + resource.Schema["cluster_resource_id"].Required = false + } + + return resource } func resourceKustoAttachedDatabaseConfigurationCreateUpdate(d *pluginsdk.ResourceData, meta interface{}) error { diff --git a/internal/services/kusto/kusto_eventgrid_data_connection_resource.go b/internal/services/kusto/kusto_eventgrid_data_connection_resource.go index 2334b4baf7ca..8b543bf033ec 100644 --- a/internal/services/kusto/kusto_eventgrid_data_connection_resource.go +++ b/internal/services/kusto/kusto_eventgrid_data_connection_resource.go @@ -5,6 +5,7 @@ package kusto import ( "fmt" + "github.com/hashicorp/terraform-provider-azurerm/internal/features" "log" "time" @@ -29,7 +30,7 @@ import ( ) func resourceKustoEventGridDataConnection() *pluginsdk.Resource { - return &pluginsdk.Resource{ + resource := &pluginsdk.Resource{ Create: resourceKustoEventGridDataConnectionCreateUpdate, Update: resourceKustoEventGridDataConnectionCreateUpdate, Read: resourceKustoEventGridDataConnectionRead, @@ -154,6 +155,31 @@ func resourceKustoEventGridDataConnection() *pluginsdk.Resource { }, }, } + + if !features.FivePointOhBeta() { + resource.Schema["eventgrid_event_subscription_id"] = &pluginsdk.Schema{ + Type: pluginsdk.TypeString, + Optional: true, + ValidateFunc: eventsubscriptions.ValidateScopedEventSubscriptionID, + Deprecated: "Use `eventgrid_resource_id` instead.", + ConflictsWith: []string{"eventgrid_resource_id"}, + } + resource.Schema["eventgrid_resource_id"].ConflictsWith = []string{"eventgrid_event_subscription_id"} + + resource.Schema["managed_identity_resource_id"] = &pluginsdk.Schema{ + Type: pluginsdk.TypeString, + Optional: true, + ValidateFunc: validation.Any( + commonids.ValidateKustoClusterID, + commonids.ValidateUserAssignedIdentityID, + ), + Deprecated: "Use `managed_identity_id` instead.", + ConflictsWith: []string{"managed_identity_id"}, + } + resource.Schema["managed_identity_id"].ConflictsWith = []string{"managed_identity_resource_id"} + } + + return resource } func resourceKustoEventGridDataConnectionCreateUpdate(d *pluginsdk.ResourceData, meta interface{}) error { From 526fc6ad052a2a3494217b3830affba9169af2fd Mon Sep 17 00:00:00 2001 From: Wyatt Fry Date: Mon, 27 Jan 2025 14:15:44 -0500 Subject: [PATCH 03/28] imports sorted --- .../kusto/kusto_attached_database_configuration_resource.go | 2 +- .../services/kusto/kusto_eventgrid_data_connection_resource.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/internal/services/kusto/kusto_attached_database_configuration_resource.go b/internal/services/kusto/kusto_attached_database_configuration_resource.go index 0507e0052ae1..f56b3c3074f2 100644 --- a/internal/services/kusto/kusto_attached_database_configuration_resource.go +++ b/internal/services/kusto/kusto_attached_database_configuration_resource.go @@ -5,7 +5,6 @@ package kusto import ( "fmt" - "github.com/hashicorp/terraform-provider-azurerm/internal/features" "time" "github.com/hashicorp/go-azure-helpers/lang/response" @@ -15,6 +14,7 @@ import ( "github.com/hashicorp/go-azure-sdk/resource-manager/kusto/2023-08-15/attacheddatabaseconfigurations" "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/locks" "github.com/hashicorp/terraform-provider-azurerm/internal/services/kusto/migration" "github.com/hashicorp/terraform-provider-azurerm/internal/services/kusto/validate" diff --git a/internal/services/kusto/kusto_eventgrid_data_connection_resource.go b/internal/services/kusto/kusto_eventgrid_data_connection_resource.go index 8b543bf033ec..4b7bd7f66a44 100644 --- a/internal/services/kusto/kusto_eventgrid_data_connection_resource.go +++ b/internal/services/kusto/kusto_eventgrid_data_connection_resource.go @@ -5,7 +5,6 @@ package kusto import ( "fmt" - "github.com/hashicorp/terraform-provider-azurerm/internal/features" "log" "time" @@ -20,6 +19,7 @@ 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" eventhubValidate "github.com/hashicorp/terraform-provider-azurerm/internal/services/eventhub/validate" "github.com/hashicorp/terraform-provider-azurerm/internal/services/kusto/migration" "github.com/hashicorp/terraform-provider-azurerm/internal/services/kusto/validate" From 46ea78e73219fa3b5e727e91e6f78de2a929f5c6 Mon Sep 17 00:00:00 2001 From: Wyatt Fry Date: Wed, 29 Jan 2025 13:52:09 -0500 Subject: [PATCH 04/28] wip --- .../kusto/kusto_attached_database_configuration_resource.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/internal/services/kusto/kusto_attached_database_configuration_resource.go b/internal/services/kusto/kusto_attached_database_configuration_resource.go index f56b3c3074f2..3909cd3c2da2 100644 --- a/internal/services/kusto/kusto_attached_database_configuration_resource.go +++ b/internal/services/kusto/kusto_attached_database_configuration_resource.go @@ -79,6 +79,7 @@ func resourceKustoAttachedDatabaseConfiguration() *pluginsdk.Resource { Required: true, ForceNew: true, ValidateFunc: commonids.ValidateKustoClusterID, + ExactlyOneOf: []string{"cluster_id", "cluster_resource_id"}, }, "attached_database_names": { @@ -164,7 +165,8 @@ func resourceKustoAttachedDatabaseConfiguration() *pluginsdk.Resource { Deprecated: "Use `cluster_id` instead.", } resource.Schema["cluster_id"].ConflictsWith = []string{"cluster_resource_id"} - resource.Schema["cluster_resource_id"].Required = false + resource.Schema["cluster_id"].Required = false + resource.Schema["cluster_id"].Optional = true } return resource From b998109e98330b2663b6342b8c2720d8643a3b27 Mon Sep 17 00:00:00 2001 From: Wyatt Fry Date: Mon, 3 Feb 2025 13:14:51 -0500 Subject: [PATCH 05/28] cleanup --- .../kusto_attached_database_configuration_resource.go | 8 +++++--- ...kusto_attached_database_configuration_resource_test.go | 2 +- .../r/kusto_attached_database_configuration.html.markdown | 2 +- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/internal/services/kusto/kusto_attached_database_configuration_resource.go b/internal/services/kusto/kusto_attached_database_configuration_resource.go index 3909cd3c2da2..65e150c830fc 100644 --- a/internal/services/kusto/kusto_attached_database_configuration_resource.go +++ b/internal/services/kusto/kusto_attached_database_configuration_resource.go @@ -79,7 +79,6 @@ func resourceKustoAttachedDatabaseConfiguration() *pluginsdk.Resource { Required: true, ForceNew: true, ValidateFunc: commonids.ValidateKustoClusterID, - ExactlyOneOf: []string{"cluster_id", "cluster_resource_id"}, }, "attached_database_names": { @@ -156,10 +155,13 @@ func resourceKustoAttachedDatabaseConfiguration() *pluginsdk.Resource { }, } - if !features.FivePointOhBeta() { + if !features.FivePointOh() { + resource.Schema["cluster_id"].Required = false + resource.Schema["cluster_id"].Optional = true + resource.Schema["cluster_id"].AtLeastOneOf = []string{"cluster_id", "cluster_resource_id"} resource.Schema["cluster_resource_id"] = &pluginsdk.Schema{ Type: pluginsdk.TypeString, - Required: true, + Required: false, ForceNew: true, ValidateFunc: commonids.ValidateKustoClusterID, Deprecated: "Use `cluster_id` instead.", diff --git a/internal/services/kusto/kusto_attached_database_configuration_resource_test.go b/internal/services/kusto/kusto_attached_database_configuration_resource_test.go index d50f2624e1bc..9a1da3853d99 100644 --- a/internal/services/kusto/kusto_attached_database_configuration_resource_test.go +++ b/internal/services/kusto/kusto_attached_database_configuration_resource_test.go @@ -104,7 +104,7 @@ resource "azurerm_kusto_attached_database_configuration" "test" { resource_group_name = azurerm_resource_group.rg.name location = azurerm_resource_group.rg.location cluster_name = azurerm_kusto_cluster.cluster1.name - cluster_resource_id = azurerm_kusto_cluster.cluster2.id + cluster_id = azurerm_kusto_cluster.cluster2.id database_name = azurerm_kusto_database.test.name sharing { diff --git a/website/docs/r/kusto_attached_database_configuration.html.markdown b/website/docs/r/kusto_attached_database_configuration.html.markdown index b21caaa8703b..2fd20965d244 100644 --- a/website/docs/r/kusto_attached_database_configuration.html.markdown +++ b/website/docs/r/kusto_attached_database_configuration.html.markdown @@ -85,7 +85,7 @@ The following arguments are supported: * `cluster_name` - (Required) Specifies the name of the Kusto Cluster for which the configuration will be created. Changing this forces a new resource to be created. -* `cluster_resource_id` - (Required) The resource id of the cluster where the databases you would like to attach reside. Changing this forces a new resource to be created. +* `cluster_id` - (Required) The resource id of the cluster where the databases you would like to attach reside. Changing this forces a new resource to be created. * `database_name` - (Required) The name of the database which you would like to attach, use * if you want to follow all current and future databases. Changing this forces a new resource to be created. From c7685b01291a50f4d20579a4bcfd84bb26d76c2c Mon Sep 17 00:00:00 2001 From: Wyatt Fry Date: Mon, 3 Feb 2025 13:17:40 -0500 Subject: [PATCH 06/28] removed unneeded --- .../kusto/kusto_attached_database_configuration_resource.go | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/internal/services/kusto/kusto_attached_database_configuration_resource.go b/internal/services/kusto/kusto_attached_database_configuration_resource.go index 65e150c830fc..2a3f6d67c742 100644 --- a/internal/services/kusto/kusto_attached_database_configuration_resource.go +++ b/internal/services/kusto/kusto_attached_database_configuration_resource.go @@ -158,7 +158,7 @@ func resourceKustoAttachedDatabaseConfiguration() *pluginsdk.Resource { if !features.FivePointOh() { resource.Schema["cluster_id"].Required = false resource.Schema["cluster_id"].Optional = true - resource.Schema["cluster_id"].AtLeastOneOf = []string{"cluster_id", "cluster_resource_id"} + resource.Schema["cluster_id"].ExactlyOneOf = []string{"cluster_id", "cluster_resource_id"} resource.Schema["cluster_resource_id"] = &pluginsdk.Schema{ Type: pluginsdk.TypeString, Required: false, @@ -166,9 +166,6 @@ func resourceKustoAttachedDatabaseConfiguration() *pluginsdk.Resource { ValidateFunc: commonids.ValidateKustoClusterID, Deprecated: "Use `cluster_id` instead.", } - resource.Schema["cluster_id"].ConflictsWith = []string{"cluster_resource_id"} - resource.Schema["cluster_id"].Required = false - resource.Schema["cluster_id"].Optional = true } return resource From c28adb74d34a1e531e4a0cdeb2256366ac3e75a4 Mon Sep 17 00:00:00 2001 From: Wyatt Fry Date: Mon, 3 Feb 2025 13:23:38 -0500 Subject: [PATCH 07/28] docs --- .../kusto/kusto_eventgrid_data_connection_resource.go | 10 +++++----- .../r/kusto_eventgrid_data_connection.html.markdown | 4 ++-- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/internal/services/kusto/kusto_eventgrid_data_connection_resource.go b/internal/services/kusto/kusto_eventgrid_data_connection_resource.go index 4b7bd7f66a44..36d7cfe4beb6 100644 --- a/internal/services/kusto/kusto_eventgrid_data_connection_resource.go +++ b/internal/services/kusto/kusto_eventgrid_data_connection_resource.go @@ -156,15 +156,15 @@ func resourceKustoEventGridDataConnection() *pluginsdk.Resource { }, } - if !features.FivePointOhBeta() { - resource.Schema["eventgrid_event_subscription_id"] = &pluginsdk.Schema{ + if !features.FivePointOh() { + resource.Schema["eventgrid_resource_id"] = &pluginsdk.Schema{ Type: pluginsdk.TypeString, Optional: true, ValidateFunc: eventsubscriptions.ValidateScopedEventSubscriptionID, - Deprecated: "Use `eventgrid_resource_id` instead.", - ConflictsWith: []string{"eventgrid_resource_id"}, + Deprecated: "Use `eventgrid_event_subscription_id` instead.", + ConflictsWith: []string{"eventgrid_event_subscription_id"}, } - resource.Schema["eventgrid_resource_id"].ConflictsWith = []string{"eventgrid_event_subscription_id"} + resource.Schema["eventgrid_event_subscription_id"].ConflictsWith = []string{"eventgrid_resource_id"} resource.Schema["managed_identity_resource_id"] = &pluginsdk.Schema{ Type: pluginsdk.TypeString, diff --git a/website/docs/r/kusto_eventgrid_data_connection.html.markdown b/website/docs/r/kusto_eventgrid_data_connection.html.markdown index 2534c1206eda..19f6c15e1f25 100644 --- a/website/docs/r/kusto_eventgrid_data_connection.html.markdown +++ b/website/docs/r/kusto_eventgrid_data_connection.html.markdown @@ -124,9 +124,9 @@ The following arguments are supported: * `database_routing_type` - (Optional) Indication for database routing information from the data connection, by default only database routing information is allowed. Allowed values: `Single`, `Multi`. Changing this forces a new resource to be created. Defaults to `Single`. -* `eventgrid_resource_id` - (Optional) The resource ID of the event grid that is subscribed to the storage account events. +* `eventgrid_event_subscription_id` - (Optional) The resource ID of the event grid that is subscribed to the storage account events. -* `managed_identity_resource_id` - (Optional) Empty for non-managed identity based data connection. For system assigned identity, provide cluster resource Id. For user assigned identity (UAI) provide the UAI resource Id. +* `managed_identity_id` - (Optional) Empty for non-managed identity based data connection. For system assigned identity, provide cluster resource Id. For user assigned identity (UAI) provide the UAI resource Id. * `mapping_rule_name` - (Optional) Specifies the mapping rule used for the message ingestion. Mapping rule must exist before resource is created. From af70f5bee08ac879e4a941e3f9ad5ccd22aab470 Mon Sep 17 00:00:00 2001 From: Wyatt Fry Date: Mon, 3 Feb 2025 13:26:36 -0500 Subject: [PATCH 08/28] tests --- .../kusto_eventgrid_data_connection_resource_test.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/internal/services/kusto/kusto_eventgrid_data_connection_resource_test.go b/internal/services/kusto/kusto_eventgrid_data_connection_resource_test.go index 8473fdc3dc4e..4ba56aa48a63 100644 --- a/internal/services/kusto/kusto_eventgrid_data_connection_resource_test.go +++ b/internal/services/kusto/kusto_eventgrid_data_connection_resource_test.go @@ -186,8 +186,8 @@ resource "azurerm_kusto_eventgrid_data_connection" "test" { blob_storage_event_type = "Microsoft.Storage.BlobRenamed" skip_first_record = true - database_routing_type = "Multi" - eventgrid_resource_id = azurerm_eventgrid_event_subscription.test.id + database_routing_type = "Multi" + eventgrid_event_subscription_id = azurerm_eventgrid_event_subscription.test.id depends_on = [azurerm_eventgrid_event_subscription.test] } @@ -231,7 +231,7 @@ resource "azurerm_kusto_eventgrid_data_connection" "test" { storage_account_id = azurerm_storage_account.test.id eventhub_id = azurerm_eventhub.test.id eventhub_consumer_group_name = azurerm_eventhub_consumer_group.test.name - managed_identity_resource_id = azurerm_user_assigned_identity.test.id + managed_identity_id = azurerm_user_assigned_identity.test.id depends_on = [azurerm_eventgrid_event_subscription.test] } `, r.template(data), data.RandomInteger) @@ -249,7 +249,7 @@ resource "azurerm_kusto_eventgrid_data_connection" "test" { storage_account_id = azurerm_storage_account.test.id eventhub_id = azurerm_eventhub.test.id eventhub_consumer_group_name = azurerm_eventhub_consumer_group.test.name - managed_identity_resource_id = azurerm_kusto_cluster.test.id + managed_identity_id = azurerm_kusto_cluster.test.id depends_on = [azurerm_eventgrid_event_subscription.test] } `, r.template(data), data.RandomInteger) From 7959930b6e28273b76e689863b42176e66fc07fb Mon Sep 17 00:00:00 2001 From: Wyatt Fry Date: Mon, 3 Feb 2025 13:34:20 -0500 Subject: [PATCH 09/28] fix --- .../kusto/kusto_attached_database_configuration_resource.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/internal/services/kusto/kusto_attached_database_configuration_resource.go b/internal/services/kusto/kusto_attached_database_configuration_resource.go index 2a3f6d67c742..c4dd7ab6a077 100644 --- a/internal/services/kusto/kusto_attached_database_configuration_resource.go +++ b/internal/services/kusto/kusto_attached_database_configuration_resource.go @@ -161,10 +161,11 @@ func resourceKustoAttachedDatabaseConfiguration() *pluginsdk.Resource { resource.Schema["cluster_id"].ExactlyOneOf = []string{"cluster_id", "cluster_resource_id"} resource.Schema["cluster_resource_id"] = &pluginsdk.Schema{ Type: pluginsdk.TypeString, - Required: false, + Optional: true, ForceNew: true, ValidateFunc: commonids.ValidateKustoClusterID, Deprecated: "Use `cluster_id` instead.", + ExactlyOneOf: []string{"cluster_id", "cluster_resource_id"}, } } From a0947ee97bdc92666d85c1a801f87394708ef266 Mon Sep 17 00:00:00 2001 From: Wyatt Fry Date: Mon, 3 Feb 2025 14:24:57 -0500 Subject: [PATCH 10/28] implementing read changes --- ...ttached_database_configuration_resource.go | 12 +++++++-- ...usto_eventgrid_data_connection_resource.go | 25 ++++++++++++++++--- 2 files changed, 31 insertions(+), 6 deletions(-) diff --git a/internal/services/kusto/kusto_attached_database_configuration_resource.go b/internal/services/kusto/kusto_attached_database_configuration_resource.go index c4dd7ab6a077..d257e644bd3a 100644 --- a/internal/services/kusto/kusto_attached_database_configuration_resource.go +++ b/internal/services/kusto/kusto_attached_database_configuration_resource.go @@ -239,11 +239,15 @@ func resourceKustoAttachedDatabaseConfigurationRead(d *pluginsdk.ResourceData, m if parseErr != nil { return parseErr } - d.Set("cluster_resource_id", clusterResourceId.ID()) + d.Set("cluster_id", clusterResourceId.ID()) d.Set("database_name", props.DatabaseName) d.Set("default_principal_modification_kind", props.DefaultPrincipalsModificationKind) d.Set("attached_database_names", props.AttachedDatabaseNames) d.Set("sharing", flattenAttachedDatabaseConfigurationTableLevelSharingProperties(props.TableLevelSharingProperties)) + + if !features.FivePointOh() { + d.Set("cluster_resource_id", clusterResourceId.ID()) + } } } @@ -275,7 +279,11 @@ func resourceKustoAttachedDatabaseConfigurationDelete(d *pluginsdk.ResourceData, func expandKustoAttachedDatabaseConfigurationProperties(d *pluginsdk.ResourceData) *attacheddatabaseconfigurations.AttachedDatabaseConfigurationProperties { AttachedDatabaseConfigurationProperties := &attacheddatabaseconfigurations.AttachedDatabaseConfigurationProperties{} - if clusterResourceID, ok := d.GetOk("cluster_resource_id"); ok { + if clusterResourceID, ok := d.GetOk("cluster_id"); ok { + AttachedDatabaseConfigurationProperties.ClusterResourceId = clusterResourceID.(string) + } + + if clusterResourceID, ok := d.GetOk("cluster_resource_id"); !features.FivePointOh() && ok { AttachedDatabaseConfigurationProperties.ClusterResourceId = clusterResourceID.(string) } diff --git a/internal/services/kusto/kusto_eventgrid_data_connection_resource.go b/internal/services/kusto/kusto_eventgrid_data_connection_resource.go index 36d7cfe4beb6..23ae0d3401a0 100644 --- a/internal/services/kusto/kusto_eventgrid_data_connection_resource.go +++ b/internal/services/kusto/kusto_eventgrid_data_connection_resource.go @@ -235,11 +235,19 @@ func resourceKustoEventGridDataConnectionCreateUpdate(d *pluginsdk.ResourceData, dataConnection.Properties.DatabaseRouting = &databaseRoutingType } - if eventGridRID, ok := d.GetOk("eventgrid_resource_id"); ok { + if eventGridRID, ok := d.GetOk("eventgrid_event_subscription_id"); ok { dataConnection.Properties.EventGridResourceId = utils.String(eventGridRID.(string)) } - if managedIdentityRID, ok := d.GetOk("managed_identity_resource_id"); ok { + if eventGridRID, ok := d.GetOk("eventgrid_resource_id"); !features.FivePointOh() && ok { + dataConnection.Properties.EventGridResourceId = utils.String(eventGridRID.(string)) + } + + if managedIdentityRID, ok := d.GetOk("managed_identity_id"); ok { + dataConnection.Properties.ManagedIdentityResourceId = utils.String(managedIdentityRID.(string)) + } + + if managedIdentityRID, ok := d.GetOk("managed_identity_resource_id"); !features.FivePointOh() && ok { dataConnection.Properties.ManagedIdentityResourceId = utils.String(managedIdentityRID.(string)) } @@ -290,7 +298,11 @@ func resourceKustoEventGridDataConnectionRead(d *pluginsdk.ResourceData, meta in d.Set("mapping_rule_name", props.MappingRuleName) d.Set("data_format", string(pointer.From(props.DataFormat))) d.Set("database_routing_type", string(pointer.From(props.DatabaseRouting))) - d.Set("eventgrid_resource_id", props.EventGridResourceId) + d.Set("eventgrid_event_subscription_id", props.EventGridResourceId) + + if !features.FivePointOh() { + d.Set("eventgrid_resource_id", props.EventGridResourceId) + } managedIdentityResourceId := "" if props.ManagedIdentityResourceId != nil && *props.ManagedIdentityResourceId != "" { @@ -307,7 +319,12 @@ func resourceKustoEventGridDataConnectionRead(d *pluginsdk.ResourceData, meta in } } } - d.Set("managed_identity_resource_id", managedIdentityResourceId) + + d.Set("managed_identity_id", managedIdentityResourceId) + + if !features.FivePointOh() { + d.Set("managed_identity_resource_id", managedIdentityResourceId) + } } } } From 28d1212fd53aa76badb423f0928eaf8f68cdf796 Mon Sep 17 00:00:00 2001 From: Wyatt Fry Date: Mon, 3 Feb 2025 14:30:29 -0500 Subject: [PATCH 11/28] fixes --- .../services/kusto/kusto_eventgrid_data_connection_resource.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/internal/services/kusto/kusto_eventgrid_data_connection_resource.go b/internal/services/kusto/kusto_eventgrid_data_connection_resource.go index 23ae0d3401a0..d52a6d285e47 100644 --- a/internal/services/kusto/kusto_eventgrid_data_connection_resource.go +++ b/internal/services/kusto/kusto_eventgrid_data_connection_resource.go @@ -315,7 +315,7 @@ func resourceKustoEventGridDataConnectionRead(d *pluginsdk.ResourceData, meta in if userAssignedIdentityIdErr == nil { managedIdentityResourceId = userAssignedIdentityId.ID() } else { - return fmt.Errorf("parsing `managed_identity_resource_id`: %+v; %+v", clusterIdErr, userAssignedIdentityIdErr) + return fmt.Errorf("parsing `managed_identity_id`: %+v; %+v", clusterIdErr, userAssignedIdentityIdErr) } } } From 15423114104ac2b2e02b6beede280d9c68467562 Mon Sep 17 00:00:00 2001 From: Wyatt Fry Date: Mon, 3 Feb 2025 17:48:49 -0500 Subject: [PATCH 12/28] add computed --- ...ttached_database_configuration_resource.go | 2 ++ ...usto_eventgrid_data_connection_resource.go | 4 ++++ ...eventgrid_data_connection_resource_test.go | 22 ++++++++++++++++++- 3 files changed, 27 insertions(+), 1 deletion(-) diff --git a/internal/services/kusto/kusto_attached_database_configuration_resource.go b/internal/services/kusto/kusto_attached_database_configuration_resource.go index d257e644bd3a..b172456b1a01 100644 --- a/internal/services/kusto/kusto_attached_database_configuration_resource.go +++ b/internal/services/kusto/kusto_attached_database_configuration_resource.go @@ -158,10 +158,12 @@ func resourceKustoAttachedDatabaseConfiguration() *pluginsdk.Resource { if !features.FivePointOh() { resource.Schema["cluster_id"].Required = false resource.Schema["cluster_id"].Optional = true + resource.Schema["cluster_id"].Computed = true resource.Schema["cluster_id"].ExactlyOneOf = []string{"cluster_id", "cluster_resource_id"} resource.Schema["cluster_resource_id"] = &pluginsdk.Schema{ Type: pluginsdk.TypeString, Optional: true, + Computed: true, ForceNew: true, ValidateFunc: commonids.ValidateKustoClusterID, Deprecated: "Use `cluster_id` instead.", diff --git a/internal/services/kusto/kusto_eventgrid_data_connection_resource.go b/internal/services/kusto/kusto_eventgrid_data_connection_resource.go index d52a6d285e47..9e77640561e4 100644 --- a/internal/services/kusto/kusto_eventgrid_data_connection_resource.go +++ b/internal/services/kusto/kusto_eventgrid_data_connection_resource.go @@ -160,15 +160,18 @@ func resourceKustoEventGridDataConnection() *pluginsdk.Resource { resource.Schema["eventgrid_resource_id"] = &pluginsdk.Schema{ Type: pluginsdk.TypeString, Optional: true, + Computed: true, ValidateFunc: eventsubscriptions.ValidateScopedEventSubscriptionID, Deprecated: "Use `eventgrid_event_subscription_id` instead.", ConflictsWith: []string{"eventgrid_event_subscription_id"}, } resource.Schema["eventgrid_event_subscription_id"].ConflictsWith = []string{"eventgrid_resource_id"} + resource.Schema["eventgrid_event_subscription_id"].Computed = true resource.Schema["managed_identity_resource_id"] = &pluginsdk.Schema{ Type: pluginsdk.TypeString, Optional: true, + Computed: true, ValidateFunc: validation.Any( commonids.ValidateKustoClusterID, commonids.ValidateUserAssignedIdentityID, @@ -177,6 +180,7 @@ func resourceKustoEventGridDataConnection() *pluginsdk.Resource { ConflictsWith: []string{"managed_identity_id"}, } resource.Schema["managed_identity_id"].ConflictsWith = []string{"managed_identity_resource_id"} + resource.Schema["managed_identity_id"].Computed = true } return resource diff --git a/internal/services/kusto/kusto_eventgrid_data_connection_resource_test.go b/internal/services/kusto/kusto_eventgrid_data_connection_resource_test.go index 4ba56aa48a63..a5960a543e37 100644 --- a/internal/services/kusto/kusto_eventgrid_data_connection_resource_test.go +++ b/internal/services/kusto/kusto_eventgrid_data_connection_resource_test.go @@ -6,6 +6,7 @@ package kusto_test import ( "context" "fmt" + "github.com/hashicorp/terraform-provider-azurerm/internal/features" "testing" "github.com/hashicorp/go-azure-sdk/resource-manager/kusto/2023-08-15/dataconnections" @@ -81,7 +82,8 @@ func TestAccKustoEventGridDataConnection_mappingRule(t *testing.T) { func TestAccKustoEventGridDataConnection_userAssignedIdentity(t *testing.T) { data := acceptance.BuildTestData(t, "azurerm_kusto_eventgrid_data_connection", "test") r := KustoEventGridDataConnectionResource{} - + fmt.Println(r.userAssignedIdentity(data)) + t.Skip() data.ResourceTest(t, r, []acceptance.TestStep{ { Config: r.userAssignedIdentity(data), @@ -238,6 +240,24 @@ resource "azurerm_kusto_eventgrid_data_connection" "test" { } func (r KustoEventGridDataConnectionResource) systemAssignedIdentity(data acceptance.TestData) string { + if !features.FivePointOh() { + return fmt.Sprintf(` +%s +resource "azurerm_kusto_eventgrid_data_connection" "test" { + name = "acctestkrgdc-%d" + resource_group_name = azurerm_resource_group.test.name + location = azurerm_resource_group.test.location + cluster_name = azurerm_kusto_cluster.test.name + database_name = azurerm_kusto_database.test.name + storage_account_id = azurerm_storage_account.test.id + eventhub_id = azurerm_eventhub.test.id + eventhub_consumer_group_name = azurerm_eventhub_consumer_group.test.name + managed_identity_resource_id = azurerm_kusto_cluster.test.id + depends_on = [azurerm_eventgrid_event_subscription.test] +} +`, r.template(data), data.RandomInteger) + } + return fmt.Sprintf(` %s resource "azurerm_kusto_eventgrid_data_connection" "test" { From 6518a8c30cdb614cd678956b562c7ed3ef438cc0 Mon Sep 17 00:00:00 2001 From: Wyatt Fry Date: Mon, 3 Feb 2025 19:51:50 -0500 Subject: [PATCH 13/28] fmt --- .../kusto/kusto_eventgrid_data_connection_resource_test.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/internal/services/kusto/kusto_eventgrid_data_connection_resource_test.go b/internal/services/kusto/kusto_eventgrid_data_connection_resource_test.go index a5960a543e37..64388d6465e5 100644 --- a/internal/services/kusto/kusto_eventgrid_data_connection_resource_test.go +++ b/internal/services/kusto/kusto_eventgrid_data_connection_resource_test.go @@ -6,9 +6,10 @@ package kusto_test import ( "context" "fmt" - "github.com/hashicorp/terraform-provider-azurerm/internal/features" "testing" + "github.com/hashicorp/terraform-provider-azurerm/internal/features" + "github.com/hashicorp/go-azure-sdk/resource-manager/kusto/2023-08-15/dataconnections" "github.com/hashicorp/terraform-provider-azurerm/internal/acceptance" "github.com/hashicorp/terraform-provider-azurerm/internal/acceptance/check" From e506264be8619519f4cd6988b0979348d8b4fc28 Mon Sep 17 00:00:00 2001 From: Wyatt Fry Date: Tue, 4 Feb 2025 08:42:02 -0500 Subject: [PATCH 14/28] fmt --- .../kusto/kusto_eventgrid_data_connection_resource_test.go | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/internal/services/kusto/kusto_eventgrid_data_connection_resource_test.go b/internal/services/kusto/kusto_eventgrid_data_connection_resource_test.go index 64388d6465e5..f466619e966e 100644 --- a/internal/services/kusto/kusto_eventgrid_data_connection_resource_test.go +++ b/internal/services/kusto/kusto_eventgrid_data_connection_resource_test.go @@ -8,12 +8,11 @@ import ( "fmt" "testing" - "github.com/hashicorp/terraform-provider-azurerm/internal/features" - "github.com/hashicorp/go-azure-sdk/resource-manager/kusto/2023-08-15/dataconnections" "github.com/hashicorp/terraform-provider-azurerm/internal/acceptance" "github.com/hashicorp/terraform-provider-azurerm/internal/acceptance/check" "github.com/hashicorp/terraform-provider-azurerm/internal/clients" + "github.com/hashicorp/terraform-provider-azurerm/internal/features" "github.com/hashicorp/terraform-provider-azurerm/internal/tf/pluginsdk" ) From e02c82c79abf27f0715aa0741c83fb2cef100d18 Mon Sep 17 00:00:00 2001 From: Wyatt Fry Date: Tue, 4 Feb 2025 10:58:13 -0500 Subject: [PATCH 15/28] Apply suggestions from code review Co-authored-by: stephybun --- ...usto_attached_database_configuration_resource.go | 13 ++++++++----- .../kusto_eventgrid_data_connection_resource.go | 4 ++-- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/internal/services/kusto/kusto_attached_database_configuration_resource.go b/internal/services/kusto/kusto_attached_database_configuration_resource.go index b172456b1a01..9fa7bd78772e 100644 --- a/internal/services/kusto/kusto_attached_database_configuration_resource.go +++ b/internal/services/kusto/kusto_attached_database_configuration_resource.go @@ -156,17 +156,20 @@ func resourceKustoAttachedDatabaseConfiguration() *pluginsdk.Resource { } if !features.FivePointOh() { - resource.Schema["cluster_id"].Required = false - resource.Schema["cluster_id"].Optional = true - resource.Schema["cluster_id"].Computed = true - resource.Schema["cluster_id"].ExactlyOneOf = []string{"cluster_id", "cluster_resource_id"} + resource.Schema["cluster_id"] = &pluginsdk.Schema{ + Type: pluginsdk.TypeString, + Optional: true, + Computed: true, + ExactlyOneOf: []string{"cluster_id", "cluster_resource_id"}, + ValidateFunc: commonids.ValidateKustoClusterID, + } resource.Schema["cluster_resource_id"] = &pluginsdk.Schema{ Type: pluginsdk.TypeString, Optional: true, Computed: true, ForceNew: true, ValidateFunc: commonids.ValidateKustoClusterID, - Deprecated: "Use `cluster_id` instead.", + Deprecated: "`cluster_resource_id` has been deprecated in favour of the `cluster_id` property and will be removed in v5.0 of the AzureRM Provider.", ExactlyOneOf: []string{"cluster_id", "cluster_resource_id"}, } } diff --git a/internal/services/kusto/kusto_eventgrid_data_connection_resource.go b/internal/services/kusto/kusto_eventgrid_data_connection_resource.go index 9e77640561e4..dc9f216b1f47 100644 --- a/internal/services/kusto/kusto_eventgrid_data_connection_resource.go +++ b/internal/services/kusto/kusto_eventgrid_data_connection_resource.go @@ -162,7 +162,7 @@ func resourceKustoEventGridDataConnection() *pluginsdk.Resource { Optional: true, Computed: true, ValidateFunc: eventsubscriptions.ValidateScopedEventSubscriptionID, - Deprecated: "Use `eventgrid_event_subscription_id` instead.", + Deprecated: "`eventgrid_resource_id` has been deprecated in favour of the `eventgrid_event_subscription_id` property and will be removed in v5.0 of the AzureRM Provider.", ConflictsWith: []string{"eventgrid_event_subscription_id"}, } resource.Schema["eventgrid_event_subscription_id"].ConflictsWith = []string{"eventgrid_resource_id"} @@ -176,7 +176,7 @@ func resourceKustoEventGridDataConnection() *pluginsdk.Resource { commonids.ValidateKustoClusterID, commonids.ValidateUserAssignedIdentityID, ), - Deprecated: "Use `managed_identity_id` instead.", + Deprecated: "`managed_identity_resource_id` has been deprecated in favour of the `managed_identity_id` property and will be removed in v5.0 of the AzureRM Provider.", ConflictsWith: []string{"managed_identity_id"}, } resource.Schema["managed_identity_id"].ConflictsWith = []string{"managed_identity_resource_id"} From f2ce1b61b2c5b49778e4787c1bc46d50e4180888 Mon Sep 17 00:00:00 2001 From: Wyatt Fry Date: Tue, 4 Feb 2025 11:11:09 -0500 Subject: [PATCH 16/28] pr feedback --- ...ed_database_configuration_resource_test.go | 86 +++++++++++++++++++ ...eventgrid_data_connection_resource_test.go | 2 - 2 files changed, 86 insertions(+), 2 deletions(-) diff --git a/internal/services/kusto/kusto_attached_database_configuration_resource_test.go b/internal/services/kusto/kusto_attached_database_configuration_resource_test.go index 9a1da3853d99..dd06f0380623 100644 --- a/internal/services/kusto/kusto_attached_database_configuration_resource_test.go +++ b/internal/services/kusto/kusto_attached_database_configuration_resource_test.go @@ -6,6 +6,7 @@ package kusto_test import ( "context" "fmt" + "github.com/hashicorp/terraform-provider-azurerm/internal/features" "testing" "github.com/hashicorp/go-azure-sdk/resource-manager/kusto/2023-08-15/attacheddatabaseconfigurations" @@ -32,6 +33,24 @@ func TestAccKustoAttachedDatabaseConfiguration_basic(t *testing.T) { }) } +func TestAccKustoAttachedDatabaseConfiguration_clusterResourceId(t *testing.T) { + if features.FivePointOh() { + t.Skip() + } + data := acceptance.BuildTestData(t, "azurerm_kusto_attached_database_configuration", "test") + r := KustoAttachedDatabaseConfigurationResource{} + + data.ResourceTest(t, r, []acceptance.TestStep{ + { + Config: r.clusterResourceId(data), + Check: acceptance.ComposeTestCheckFunc( + check.That(data.ResourceName).ExistsInAzure(r), + ), + }, + data.ImportStep(), + }) +} + func (KustoAttachedDatabaseConfigurationResource) Exists(ctx context.Context, clients *clients.Client, state *pluginsdk.InstanceState) (*bool, error) { id, err := attacheddatabaseconfigurations.ParseAttachedDatabaseConfigurationID(state.ID) if err != nil { @@ -118,3 +137,70 @@ resource "azurerm_kusto_attached_database_configuration" "test" { } `, data.RandomInteger, data.Locations.Primary, data.RandomString, data.RandomString, data.RandomInteger, data.RandomInteger, data.RandomInteger) } + +func (KustoAttachedDatabaseConfigurationResource) clusterResourceId(data acceptance.TestData) string { + return fmt.Sprintf(` +provider "azurerm" { + features {} +} + +resource "azurerm_resource_group" "rg" { + name = "acctestRG-%d" + location = "%s" +} + +resource "azurerm_kusto_cluster" "cluster1" { + name = "acctestkc1%s" + location = azurerm_resource_group.rg.location + resource_group_name = azurerm_resource_group.rg.name + + sku { + name = "Dev(No SLA)_Standard_D11_v2" + capacity = 1 + } +} + +resource "azurerm_kusto_cluster" "cluster2" { + name = "acctestkc2%s" + location = azurerm_resource_group.rg.location + resource_group_name = azurerm_resource_group.rg.name + + sku { + name = "Dev(No SLA)_Standard_D11_v2" + capacity = 1 + } +} + +resource "azurerm_kusto_database" "followed_database" { + name = "acctestkd-%d" + resource_group_name = azurerm_resource_group.rg.name + location = azurerm_resource_group.rg.location + cluster_name = azurerm_kusto_cluster.cluster1.name +} + +resource "azurerm_kusto_database" "test" { + name = "acctestkd2-%d" + resource_group_name = azurerm_resource_group.rg.name + location = azurerm_resource_group.rg.location + cluster_name = azurerm_kusto_cluster.cluster2.name +} + +resource "azurerm_kusto_attached_database_configuration" "test" { + name = "acctestka-%d" + resource_group_name = azurerm_resource_group.rg.name + location = azurerm_resource_group.rg.location + cluster_name = azurerm_kusto_cluster.cluster1.name + cluster_resource_id = azurerm_kusto_cluster.cluster2.id + database_name = azurerm_kusto_database.test.name + + sharing { + external_tables_to_exclude = ["ExternalTable2"] + external_tables_to_include = ["ExternalTable1"] + materialized_views_to_exclude = ["MaterializedViewTable2"] + materialized_views_to_include = ["MaterializedViewTable1"] + tables_to_exclude = ["Table2"] + tables_to_include = ["Table1"] + } +} +`, data.RandomInteger, data.Locations.Primary, data.RandomString, data.RandomString, data.RandomInteger, data.RandomInteger, data.RandomInteger) +} diff --git a/internal/services/kusto/kusto_eventgrid_data_connection_resource_test.go b/internal/services/kusto/kusto_eventgrid_data_connection_resource_test.go index f466619e966e..f032a727927e 100644 --- a/internal/services/kusto/kusto_eventgrid_data_connection_resource_test.go +++ b/internal/services/kusto/kusto_eventgrid_data_connection_resource_test.go @@ -82,8 +82,6 @@ func TestAccKustoEventGridDataConnection_mappingRule(t *testing.T) { func TestAccKustoEventGridDataConnection_userAssignedIdentity(t *testing.T) { data := acceptance.BuildTestData(t, "azurerm_kusto_eventgrid_data_connection", "test") r := KustoEventGridDataConnectionResource{} - fmt.Println(r.userAssignedIdentity(data)) - t.Skip() data.ResourceTest(t, r, []acceptance.TestStep{ { Config: r.userAssignedIdentity(data), From a4e0cca606c0f597adbd5486a0840128176165a2 Mon Sep 17 00:00:00 2001 From: Wyatt Fry Date: Tue, 4 Feb 2025 12:21:35 -0500 Subject: [PATCH 17/28] more tests for deprecated props --- ...ed_database_configuration_resource_test.go | 2 +- ...eventgrid_data_connection_resource_test.go | 108 +++++++++++++++++- 2 files changed, 104 insertions(+), 6 deletions(-) diff --git a/internal/services/kusto/kusto_attached_database_configuration_resource_test.go b/internal/services/kusto/kusto_attached_database_configuration_resource_test.go index dd06f0380623..1e5fa5857e89 100644 --- a/internal/services/kusto/kusto_attached_database_configuration_resource_test.go +++ b/internal/services/kusto/kusto_attached_database_configuration_resource_test.go @@ -190,7 +190,7 @@ resource "azurerm_kusto_attached_database_configuration" "test" { resource_group_name = azurerm_resource_group.rg.name location = azurerm_resource_group.rg.location cluster_name = azurerm_kusto_cluster.cluster1.name - cluster_resource_id = azurerm_kusto_cluster.cluster2.id + cluster_resource_id = azurerm_kusto_cluster.cluster2.id ### <-- Testing this deprecated property database_name = azurerm_kusto_database.test.name sharing { diff --git a/internal/services/kusto/kusto_eventgrid_data_connection_resource_test.go b/internal/services/kusto/kusto_eventgrid_data_connection_resource_test.go index f032a727927e..46c2f3cb985f 100644 --- a/internal/services/kusto/kusto_eventgrid_data_connection_resource_test.go +++ b/internal/services/kusto/kusto_eventgrid_data_connection_resource_test.go @@ -64,6 +64,26 @@ func TestAccKustoEventGridDataConnection_complete(t *testing.T) { }) } +func TestAccKustoEventGridDataConnection_eventgridResourceId(t *testing.T) { + if features.FivePointOh() { + t.Skip() + } + + data := acceptance.BuildTestData(t, "azurerm_kusto_eventgrid_data_connection", "test") + r := KustoEventGridDataConnectionResource{} + + data.ResourceTest(t, r, []acceptance.TestStep{ + { + Config: r.eventgridResourceId(data), + Check: acceptance.ComposeTestCheckFunc( + check.That(data.ResourceName).ExistsInAzure(r), + check.That(data.ResourceName).Key("database_routing_type").HasValue("Multi"), + ), + }, + data.ImportStep(), + }) +} + func TestAccKustoEventGridDataConnection_mappingRule(t *testing.T) { data := acceptance.BuildTestData(t, "azurerm_kusto_eventgrid_data_connection", "test") r := KustoEventGridDataConnectionResource{} @@ -108,6 +128,41 @@ func TestAccKustoEventGridDataConnection_systemAssignedIdentity(t *testing.T) { }) } +func TestAccKustoEventGridDataConnection_userAssignedIdentityResourceId(t *testing.T) { + if features.FivePointOh() { + t.Skip() + } + data := acceptance.BuildTestData(t, "azurerm_kusto_eventgrid_data_connection", "test") + r := KustoEventGridDataConnectionResource{} + data.ResourceTest(t, r, []acceptance.TestStep{ + { + Config: r.userAssignedIdentityResourceId(data), + Check: acceptance.ComposeTestCheckFunc( + check.That(data.ResourceName).ExistsInAzure(r), + ), + }, + data.ImportStep(), + }) +} + +func TestAccKustoEventGridDataConnection_systemAssignedIdentityResourceId(t *testing.T) { + if features.FivePointOh() { + t.Skip() + } + data := acceptance.BuildTestData(t, "azurerm_kusto_eventgrid_data_connection", "test") + r := KustoEventGridDataConnectionResource{} + + data.ResourceTest(t, r, []acceptance.TestStep{ + { + Config: r.systemAssignedIdentityResourceId(data), + Check: acceptance.ComposeTestCheckFunc( + check.That(data.ResourceName).ExistsInAzure(r), + ), + }, + data.ImportStep(), + }) +} + func (KustoEventGridDataConnectionResource) Exists(ctx context.Context, clients *clients.Client, state *pluginsdk.InstanceState) (*bool, error) { id, err := dataconnections.ParseDataConnectionID(state.ID) if err != nil { @@ -194,6 +249,31 @@ resource "azurerm_kusto_eventgrid_data_connection" "test" { `, r.template(data), data.RandomInteger) } +func (r KustoEventGridDataConnectionResource) eventgridResourceId(data acceptance.TestData) string { + return fmt.Sprintf(` +%s + +resource "azurerm_kusto_eventgrid_data_connection" "test" { + name = "acctestkrgdc-%d" + resource_group_name = azurerm_resource_group.test.name + location = azurerm_resource_group.test.location + cluster_name = azurerm_kusto_cluster.test.name + database_name = azurerm_kusto_database.test.name + storage_account_id = azurerm_storage_account.test.id + eventhub_id = azurerm_eventhub.test.id + eventhub_consumer_group_name = azurerm_eventhub_consumer_group.test.name + + blob_storage_event_type = "Microsoft.Storage.BlobRenamed" + skip_first_record = true + + database_routing_type = "Multi" + eventgrid_resource_id = azurerm_eventgrid_event_subscription.test.id + + depends_on = [azurerm_eventgrid_event_subscription.test] +} +`, r.template(data), data.RandomInteger) +} + func (r KustoEventGridDataConnectionResource) mappingRule(data acceptance.TestData) string { return fmt.Sprintf(` %s @@ -238,8 +318,7 @@ resource "azurerm_kusto_eventgrid_data_connection" "test" { } func (r KustoEventGridDataConnectionResource) systemAssignedIdentity(data acceptance.TestData) string { - if !features.FivePointOh() { - return fmt.Sprintf(` + return fmt.Sprintf(` %s resource "azurerm_kusto_eventgrid_data_connection" "test" { name = "acctestkrgdc-%d" @@ -250,12 +329,13 @@ resource "azurerm_kusto_eventgrid_data_connection" "test" { storage_account_id = azurerm_storage_account.test.id eventhub_id = azurerm_eventhub.test.id eventhub_consumer_group_name = azurerm_eventhub_consumer_group.test.name - managed_identity_resource_id = azurerm_kusto_cluster.test.id + managed_identity_id = azurerm_kusto_cluster.test.id depends_on = [azurerm_eventgrid_event_subscription.test] } `, r.template(data), data.RandomInteger) - } +} +func (r KustoEventGridDataConnectionResource) userAssignedIdentityResourceId(data acceptance.TestData) string { return fmt.Sprintf(` %s resource "azurerm_kusto_eventgrid_data_connection" "test" { @@ -267,7 +347,25 @@ resource "azurerm_kusto_eventgrid_data_connection" "test" { storage_account_id = azurerm_storage_account.test.id eventhub_id = azurerm_eventhub.test.id eventhub_consumer_group_name = azurerm_eventhub_consumer_group.test.name - managed_identity_id = azurerm_kusto_cluster.test.id + managed_identity_resource_id = azurerm_user_assigned_identity.test.id + depends_on = [azurerm_eventgrid_event_subscription.test] +} +`, r.template(data), data.RandomInteger) +} + +func (r KustoEventGridDataConnectionResource) systemAssignedIdentityResourceId(data acceptance.TestData) string { + return fmt.Sprintf(` +%s +resource "azurerm_kusto_eventgrid_data_connection" "test" { + name = "acctestkrgdc-%d" + resource_group_name = azurerm_resource_group.test.name + location = azurerm_resource_group.test.location + cluster_name = azurerm_kusto_cluster.test.name + database_name = azurerm_kusto_database.test.name + storage_account_id = azurerm_storage_account.test.id + eventhub_id = azurerm_eventhub.test.id + eventhub_consumer_group_name = azurerm_eventhub_consumer_group.test.name + managed_identity_resource_id = azurerm_kusto_cluster.test.id depends_on = [azurerm_eventgrid_event_subscription.test] } `, r.template(data), data.RandomInteger) From e6ff5a7df5ff68a2c16fdaf5938cb8da0ff2d21f Mon Sep 17 00:00:00 2001 From: Wyatt Fry Date: Tue, 4 Feb 2025 12:28:25 -0500 Subject: [PATCH 18/28] fmt --- .../kusto_attached_database_configuration_resource_test.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/internal/services/kusto/kusto_attached_database_configuration_resource_test.go b/internal/services/kusto/kusto_attached_database_configuration_resource_test.go index 1e5fa5857e89..176ddc1c720b 100644 --- a/internal/services/kusto/kusto_attached_database_configuration_resource_test.go +++ b/internal/services/kusto/kusto_attached_database_configuration_resource_test.go @@ -6,9 +6,10 @@ package kusto_test import ( "context" "fmt" - "github.com/hashicorp/terraform-provider-azurerm/internal/features" "testing" + "github.com/hashicorp/terraform-provider-azurerm/internal/features" + "github.com/hashicorp/go-azure-sdk/resource-manager/kusto/2023-08-15/attacheddatabaseconfigurations" "github.com/hashicorp/terraform-provider-azurerm/internal/acceptance" "github.com/hashicorp/terraform-provider-azurerm/internal/acceptance/check" From 7e2f08568ef0ebe733cc313b9bcc3ec02bc1ce8b Mon Sep 17 00:00:00 2001 From: Wyatt Fry Date: Tue, 4 Feb 2025 14:11:19 -0500 Subject: [PATCH 19/28] fixed removed property --- internal/services/kusto/kusto_database_script_resource_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/internal/services/kusto/kusto_database_script_resource_test.go b/internal/services/kusto/kusto_database_script_resource_test.go index b0973d3a1c73..4c84cf0961d2 100644 --- a/internal/services/kusto/kusto_database_script_resource_test.go +++ b/internal/services/kusto/kusto_database_script_resource_test.go @@ -178,7 +178,7 @@ resource "azurerm_storage_account" "test" { resource "azurerm_storage_container" "test" { name = "setup-files" - storage_account_name = azurerm_storage_account.test.name + storage_account_id = azurerm_storage_account.test.id container_access_type = "private" } From 86b38f8e02aba0e8b9a4d19e28f3758b815a2e7d Mon Sep 17 00:00:00 2001 From: Wyatt Fry Date: Thu, 6 Feb 2025 13:50:39 -0500 Subject: [PATCH 20/28] kusto update --- website/docs/5.0-upgrade-guide.html.markdown | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/website/docs/5.0-upgrade-guide.html.markdown b/website/docs/5.0-upgrade-guide.html.markdown index b95692591328..765ac1962d78 100644 --- a/website/docs/5.0-upgrade-guide.html.markdown +++ b/website/docs/5.0-upgrade-guide.html.markdown @@ -124,6 +124,15 @@ Please follow the format in the example below for listing breaking changes in re * The deprecated `private_link_fast_path_enabled` property has been removed as it is no longer supported by the resource. +### `azurerm_kusto_eventgrid_data_connection` + +* The deprecated `eventgrid_resource_id` property has been removed in favour of the `eventgrid_event_subscription_id` property. +* The deprecated `managed_identity_resource_id` property has been removed in favour of the `managed_identity_id` property. + +### `azurerm_kusto_attached_database_configuration` + +* The deprecated `cluster_resource_id` property has been removed in favour of the `cluster_id` property. + ### `azurerm_logic_app_standard` * The deprecated `site_config.public_network_access_enabled` property has been removed and superseded by the `public_network_access` property. From 9fa73be3b835e0eaaa40c087b72aa6b1f887e72a Mon Sep 17 00:00:00 2001 From: Wyatt Fry Date: Thu, 6 Feb 2025 14:00:00 -0500 Subject: [PATCH 21/28] fmt --- .../kusto_attached_database_configuration_resource_test.go | 2 +- .../kusto/kusto_eventgrid_data_connection_resource_test.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/internal/services/kusto/kusto_attached_database_configuration_resource_test.go b/internal/services/kusto/kusto_attached_database_configuration_resource_test.go index 176ddc1c720b..58b38a6f4dab 100644 --- a/internal/services/kusto/kusto_attached_database_configuration_resource_test.go +++ b/internal/services/kusto/kusto_attached_database_configuration_resource_test.go @@ -191,7 +191,7 @@ resource "azurerm_kusto_attached_database_configuration" "test" { resource_group_name = azurerm_resource_group.rg.name location = azurerm_resource_group.rg.location cluster_name = azurerm_kusto_cluster.cluster1.name - cluster_resource_id = azurerm_kusto_cluster.cluster2.id ### <-- Testing this deprecated property + cluster_resource_id = azurerm_kusto_cluster.cluster2.id ### <-- Testing this deprecated property database_name = azurerm_kusto_database.test.name sharing { diff --git a/internal/services/kusto/kusto_eventgrid_data_connection_resource_test.go b/internal/services/kusto/kusto_eventgrid_data_connection_resource_test.go index 46c2f3cb985f..2454fde3f6f0 100644 --- a/internal/services/kusto/kusto_eventgrid_data_connection_resource_test.go +++ b/internal/services/kusto/kusto_eventgrid_data_connection_resource_test.go @@ -266,7 +266,7 @@ resource "azurerm_kusto_eventgrid_data_connection" "test" { blob_storage_event_type = "Microsoft.Storage.BlobRenamed" skip_first_record = true - database_routing_type = "Multi" + database_routing_type = "Multi" eventgrid_resource_id = azurerm_eventgrid_event_subscription.test.id depends_on = [azurerm_eventgrid_event_subscription.test] From 2d8615edcce1d4ab8f06132a189405405953c3b6 Mon Sep 17 00:00:00 2001 From: Wyatt Fry Date: Fri, 7 Feb 2025 16:07:59 -0500 Subject: [PATCH 22/28] WIP --- .../kusto/kusto_eventgrid_data_connection_resource_test.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/internal/services/kusto/kusto_eventgrid_data_connection_resource_test.go b/internal/services/kusto/kusto_eventgrid_data_connection_resource_test.go index 2454fde3f6f0..3ccb363efdf5 100644 --- a/internal/services/kusto/kusto_eventgrid_data_connection_resource_test.go +++ b/internal/services/kusto/kusto_eventgrid_data_connection_resource_test.go @@ -427,8 +427,9 @@ resource "azurerm_eventhub_namespace" "test" { resource "azurerm_eventhub" "test" { name = "acctesteventhub-%d" - namespace_name = azurerm_eventhub_namespace.test.name - resource_group_name = azurerm_resource_group.test.name + namespace_name = azurerm_eventhub_namespace.test.name # TODO remove two old arguments + resource_group_name = azurerm_resource_group.test.name # TODO remove two old arguments + namespace_id = azurerm_eventhub_namespace.test.id # TODO add new one partition_count = 1 message_retention = 1 } From 34b378a86e73ab70672aaa720d267be128db4959 Mon Sep 17 00:00:00 2001 From: Wyatt Fry Date: Sat, 8 Feb 2025 06:38:41 -0500 Subject: [PATCH 23/28] fix --- .../kusto/kusto_eventgrid_data_connection_resource_test.go | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/internal/services/kusto/kusto_eventgrid_data_connection_resource_test.go b/internal/services/kusto/kusto_eventgrid_data_connection_resource_test.go index 3ccb363efdf5..b528cba5b657 100644 --- a/internal/services/kusto/kusto_eventgrid_data_connection_resource_test.go +++ b/internal/services/kusto/kusto_eventgrid_data_connection_resource_test.go @@ -427,9 +427,7 @@ resource "azurerm_eventhub_namespace" "test" { resource "azurerm_eventhub" "test" { name = "acctesteventhub-%d" - namespace_name = azurerm_eventhub_namespace.test.name # TODO remove two old arguments - resource_group_name = azurerm_resource_group.test.name # TODO remove two old arguments - namespace_id = azurerm_eventhub_namespace.test.id # TODO add new one + namespace_id = azurerm_eventhub_namespace.test.id partition_count = 1 message_retention = 1 } From 09b2b79f73351782319ba0ed7c309a96ba1d5a73 Mon Sep 17 00:00:00 2001 From: Wyatt Fry Date: Sat, 8 Feb 2025 09:45:42 -0500 Subject: [PATCH 24/28] fmt --- .../kusto_eventgrid_data_connection_resource_test.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/internal/services/kusto/kusto_eventgrid_data_connection_resource_test.go b/internal/services/kusto/kusto_eventgrid_data_connection_resource_test.go index b528cba5b657..98b8956c4e8a 100644 --- a/internal/services/kusto/kusto_eventgrid_data_connection_resource_test.go +++ b/internal/services/kusto/kusto_eventgrid_data_connection_resource_test.go @@ -426,10 +426,10 @@ resource "azurerm_eventhub_namespace" "test" { } resource "azurerm_eventhub" "test" { - name = "acctesteventhub-%d" - namespace_id = azurerm_eventhub_namespace.test.id - partition_count = 1 - message_retention = 1 + name = "acctesteventhub-%d" + namespace_id = azurerm_eventhub_namespace.test.id + partition_count = 1 + message_retention = 1 } resource "azurerm_eventhub_consumer_group" "test" { From c3221c97ab3cba11c459e897000e4ccc507c4e20 Mon Sep 17 00:00:00 2001 From: Wyatt Fry Date: Wed, 12 Feb 2025 11:36:26 -0500 Subject: [PATCH 25/28] feedback --- .../kusto/kusto_attached_database_configuration_resource.go | 1 - 1 file changed, 1 deletion(-) diff --git a/internal/services/kusto/kusto_attached_database_configuration_resource.go b/internal/services/kusto/kusto_attached_database_configuration_resource.go index 9fa7bd78772e..34648594d6ba 100644 --- a/internal/services/kusto/kusto_attached_database_configuration_resource.go +++ b/internal/services/kusto/kusto_attached_database_configuration_resource.go @@ -167,7 +167,6 @@ func resourceKustoAttachedDatabaseConfiguration() *pluginsdk.Resource { Type: pluginsdk.TypeString, Optional: true, Computed: true, - ForceNew: true, ValidateFunc: commonids.ValidateKustoClusterID, Deprecated: "`cluster_resource_id` has been deprecated in favour of the `cluster_id` property and will be removed in v5.0 of the AzureRM Provider.", ExactlyOneOf: []string{"cluster_id", "cluster_resource_id"}, From 51f0dee1931469e212eec598fe85ccf94d79bb76 Mon Sep 17 00:00:00 2001 From: Wyatt Fry Date: Mon, 17 Feb 2025 09:36:21 -0500 Subject: [PATCH 26/28] Apply suggestions from code review Co-authored-by: Matthew Frahry --- .../kusto/kusto_attached_database_configuration_resource_test.go | 1 - 1 file changed, 1 deletion(-) diff --git a/internal/services/kusto/kusto_attached_database_configuration_resource_test.go b/internal/services/kusto/kusto_attached_database_configuration_resource_test.go index 58b38a6f4dab..2b58b332f636 100644 --- a/internal/services/kusto/kusto_attached_database_configuration_resource_test.go +++ b/internal/services/kusto/kusto_attached_database_configuration_resource_test.go @@ -9,7 +9,6 @@ import ( "testing" "github.com/hashicorp/terraform-provider-azurerm/internal/features" - "github.com/hashicorp/go-azure-sdk/resource-manager/kusto/2023-08-15/attacheddatabaseconfigurations" "github.com/hashicorp/terraform-provider-azurerm/internal/acceptance" "github.com/hashicorp/terraform-provider-azurerm/internal/acceptance/check" From a64811d29ed1ea530be47803d4b3ec3685228838 Mon Sep 17 00:00:00 2001 From: Wyatt Fry Date: Mon, 17 Feb 2025 09:36:54 -0500 Subject: [PATCH 27/28] sorted import --- .../kusto_attached_database_configuration_resource_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/internal/services/kusto/kusto_attached_database_configuration_resource_test.go b/internal/services/kusto/kusto_attached_database_configuration_resource_test.go index 2b58b332f636..86dda889a0f6 100644 --- a/internal/services/kusto/kusto_attached_database_configuration_resource_test.go +++ b/internal/services/kusto/kusto_attached_database_configuration_resource_test.go @@ -8,11 +8,11 @@ import ( "fmt" "testing" - "github.com/hashicorp/terraform-provider-azurerm/internal/features" "github.com/hashicorp/go-azure-sdk/resource-manager/kusto/2023-08-15/attacheddatabaseconfigurations" "github.com/hashicorp/terraform-provider-azurerm/internal/acceptance" "github.com/hashicorp/terraform-provider-azurerm/internal/acceptance/check" "github.com/hashicorp/terraform-provider-azurerm/internal/clients" + "github.com/hashicorp/terraform-provider-azurerm/internal/features" "github.com/hashicorp/terraform-provider-azurerm/internal/tf/pluginsdk" ) From 2e88d794fc55ed16e4de9a8b929f0de80e4d57c0 Mon Sep 17 00:00:00 2001 From: Wyatt Fry Date: Tue, 18 Feb 2025 13:36:36 -0500 Subject: [PATCH 28/28] 5.0 wrap --- .../kusto_attached_database_configuration_resource.go | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/internal/services/kusto/kusto_attached_database_configuration_resource.go b/internal/services/kusto/kusto_attached_database_configuration_resource.go index 34648594d6ba..9a1576214726 100644 --- a/internal/services/kusto/kusto_attached_database_configuration_resource.go +++ b/internal/services/kusto/kusto_attached_database_configuration_resource.go @@ -286,9 +286,10 @@ func expandKustoAttachedDatabaseConfigurationProperties(d *pluginsdk.ResourceDat if clusterResourceID, ok := d.GetOk("cluster_id"); ok { AttachedDatabaseConfigurationProperties.ClusterResourceId = clusterResourceID.(string) } - - if clusterResourceID, ok := d.GetOk("cluster_resource_id"); !features.FivePointOh() && ok { - AttachedDatabaseConfigurationProperties.ClusterResourceId = clusterResourceID.(string) + if !features.FivePointOh() { + if clusterResourceID, ok := d.GetOk("cluster_resource_id"); ok { + AttachedDatabaseConfigurationProperties.ClusterResourceId = clusterResourceID.(string) + } } if databaseName, ok := d.GetOk("database_name"); ok {