diff --git a/azurerm/internal/services/kusto/client/client.go b/azurerm/internal/services/kusto/client/client.go index 111b7a22dc22..3c3266934674 100644 --- a/azurerm/internal/services/kusto/client/client.go +++ b/azurerm/internal/services/kusto/client/client.go @@ -6,10 +6,11 @@ import ( ) type Client struct { - ClustersClient *kusto.ClustersClient - DatabasesClient *kusto.DatabasesClient - DataConnectionsClient *kusto.DataConnectionsClient - ClusterPrincipalAssignmentsClient *kusto.ClusterPrincipalAssignmentsClient + ClustersClient *kusto.ClustersClient + DatabasesClient *kusto.DatabasesClient + DataConnectionsClient *kusto.DataConnectionsClient + ClusterPrincipalAssignmentsClient *kusto.ClusterPrincipalAssignmentsClient + AttachedDatabaseConfigurationsClient *kusto.AttachedDatabaseConfigurationsClient } func NewClient(o *common.ClientOptions) *Client { @@ -21,14 +22,17 @@ func NewClient(o *common.ClientOptions) *Client { DataConnectionsClient := kusto.NewDataConnectionsClientWithBaseURI(o.ResourceManagerEndpoint, o.SubscriptionId) o.ConfigureClient(&DataConnectionsClient.Client, o.ResourceManagerAuthorizer) - ClusterPrincipalAssignmentsClient := kusto.NewClusterPrincipalAssignmentsClientWithBaseURI(o.ResourceManagerEndpoint, o.SubscriptionId) o.ConfigureClient(&ClusterPrincipalAssignmentsClient.Client, o.ResourceManagerAuthorizer) + AttachedDatabaseConfigurationsClient := kusto.NewAttachedDatabaseConfigurationsClientWithBaseURI(o.ResourceManagerEndpoint, o.SubscriptionId) + o.ConfigureClient(&AttachedDatabaseConfigurationsClient.Client, o.ResourceManagerAuthorizer) + return &Client{ - ClustersClient: &ClustersClient, - DatabasesClient: &DatabasesClient, - DataConnectionsClient: &DataConnectionsClient, - ClusterPrincipalAssignmentsClient: &ClusterPrincipalAssignmentsClient, + ClustersClient: &ClustersClient, + DatabasesClient: &DatabasesClient, + DataConnectionsClient: &DataConnectionsClient, + ClusterPrincipalAssignmentsClient: &ClusterPrincipalAssignmentsClient, + AttachedDatabaseConfigurationsClient: &AttachedDatabaseConfigurationsClient, } } diff --git a/azurerm/internal/services/kusto/kusto_attached_database_configuration.go b/azurerm/internal/services/kusto/kusto_attached_database_configuration.go new file mode 100644 index 000000000000..edb5ec3ffb99 --- /dev/null +++ b/azurerm/internal/services/kusto/kusto_attached_database_configuration.go @@ -0,0 +1,220 @@ +package kusto + +import ( + "fmt" + "log" + "time" + + "github.com/Azure/azure-sdk-for-go/services/kusto/mgmt/2020-02-15/kusto" + "github.com/hashicorp/terraform-plugin-sdk/helper/schema" + "github.com/hashicorp/terraform-plugin-sdk/helper/validation" + "github.com/terraform-providers/terraform-provider-azurerm/azurerm/helpers/azure" + "github.com/terraform-providers/terraform-provider-azurerm/azurerm/helpers/tf" + "github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/clients" + "github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/services/kusto/parse" + "github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/timeouts" + "github.com/terraform-providers/terraform-provider-azurerm/azurerm/utils" +) + +func resourceArmKustoAttachedDatabaseConfiguration() *schema.Resource { + return &schema.Resource{ + Create: resourceArmKustoAttachedDatabaseConfigurationCreateUpdate, + Read: resourceArmKustoAttachedDatabaseConfigurationRead, + Update: resourceArmKustoAttachedDatabaseConfigurationCreateUpdate, + Delete: resourceArmKustoAttachedDatabaseConfigurationDelete, + + Importer: &schema.ResourceImporter{ + State: schema.ImportStatePassthrough, + }, + + Timeouts: &schema.ResourceTimeout{ + Create: schema.DefaultTimeout(60 * time.Minute), + Read: schema.DefaultTimeout(5 * time.Minute), + Update: schema.DefaultTimeout(60 * time.Minute), + Delete: schema.DefaultTimeout(60 * time.Minute), + }, + + Schema: map[string]*schema.Schema{ + "name": { + Type: schema.TypeString, + Required: true, + ForceNew: true, + ValidateFunc: validateAzureRMKustoDataConnectionName, + }, + + "resource_group_name": azure.SchemaResourceGroupName(), + + "location": azure.SchemaLocation(), + + "cluster_name": { + Type: schema.TypeString, + Required: true, + ForceNew: true, + ValidateFunc: validateAzureRMKustoClusterName, + }, + + "database_name": { + Type: schema.TypeString, + Required: true, + ForceNew: true, + ValidateFunc: validation.Any(validateAzureRMKustoDatabaseName, validation.StringInSlice([]string{"*"}, false)), + }, + + "cluster_resource_id": { + Type: schema.TypeString, + Required: true, + ForceNew: true, + ValidateFunc: azure.ValidateResourceID, + }, + + "attached_database_names": { + Type: schema.TypeList, + Computed: true, + Elem: &schema.Schema{ + Type: schema.TypeString, + }, + }, + + "default_principal_modification_kind": { + Type: schema.TypeString, + Optional: true, + Default: kusto.DefaultPrincipalsModificationKindNone, + ValidateFunc: validation.StringInSlice([]string{ + string(kusto.DefaultPrincipalsModificationKindNone), + string(kusto.DefaultPrincipalsModificationKindReplace), + string(kusto.DefaultPrincipalsModificationKindUnion), + }, false), + }, + }, + } +} + +func resourceArmKustoAttachedDatabaseConfigurationCreateUpdate(d *schema.ResourceData, meta interface{}) error { + client := meta.(*clients.Client).Kusto.AttachedDatabaseConfigurationsClient + ctx, cancel := timeouts.ForCreateUpdate(meta.(*clients.Client).StopContext, d) + defer cancel() + + log.Printf("[INFO] preparing arguments for Azure Kusto Attached Database Configuration creation.") + + name := d.Get("name").(string) + resourceGroup := d.Get("resource_group_name").(string) + clusterName := d.Get("cluster_name").(string) + + if d.IsNewResource() { + resp, err := client.Get(ctx, resourceGroup, clusterName, name) + if err != nil { + if !utils.ResponseWasNotFound(resp.Response) { + return fmt.Errorf("Error checking for presence of existing Kusto Attached Database Configuration %q (Resource Group %q, Cluster %q): %s", name, resourceGroup, clusterName, err) + } + } + + if resp.ID != nil && *resp.ID != "" { + return tf.ImportAsExistsError("azurerm_kusto_attached_database_configuration", *resp.ID) + } + } + + location := azure.NormalizeLocation(d.Get("location").(string)) + + configurationProperties := expandKustoAttachedDatabaseConfigurationProperties(d) + + configurationRequest := kusto.AttachedDatabaseConfiguration{ + Location: &location, + AttachedDatabaseConfigurationProperties: configurationProperties, + } + + future, err := client.CreateOrUpdate(ctx, resourceGroup, clusterName, name, configurationRequest) + if err != nil { + return fmt.Errorf("Error creating or updating Kusto Attached Database Configuration %q (Resource Group %q, Cluster %q): %+v", name, resourceGroup, clusterName, err) + } + + if err = future.WaitForCompletionRef(ctx, client.Client); err != nil { + return fmt.Errorf("Error waiting for completion of Kusto Attached Database Configuration %q (Resource Group %q, Cluster %q): %+v", name, resourceGroup, clusterName, err) + } + + configuration, err := client.Get(ctx, resourceGroup, clusterName, name) + if err != nil { + return fmt.Errorf("Error retrieving Kusto Attached Database Configuration %q (Resource Group %q, Cluster %q): %+v", name, resourceGroup, clusterName, err) + } + + d.SetId(*configuration.ID) + + return resourceArmKustoAttachedDatabaseConfigurationRead(d, meta) +} + +func resourceArmKustoAttachedDatabaseConfigurationRead(d *schema.ResourceData, meta interface{}) error { + client := meta.(*clients.Client).Kusto.AttachedDatabaseConfigurationsClient + ctx, cancel := timeouts.ForRead(meta.(*clients.Client).StopContext, d) + defer cancel() + + id, err := parse.KustoAttachedDatabaseConfigurationID(d.Id()) + if err != nil { + return err + } + + configuration, err := client.Get(ctx, id.ResourceGroup, id.Cluster, id.Name) + + if err != nil { + if utils.ResponseWasNotFound(configuration.Response) { + d.SetId("") + return nil + } + return fmt.Errorf("Error retrieving Kusto Attached Database Configuration %q (Resource Group %q, Cluster %q): %+v", id.Name, id.ResourceGroup, id.Cluster, err) + } + + d.Set("name", id.Name) + d.Set("resource_group_name", id.ResourceGroup) + d.Set("cluster_name", id.Cluster) + + if location := configuration.Location; location != nil { + d.Set("location", azure.NormalizeLocation(*location)) + } + + if props := configuration.AttachedDatabaseConfigurationProperties; props != nil { + d.Set("cluster_resource_id", props.ClusterResourceID) + d.Set("database_name", props.DatabaseName) + d.Set("default_principal_modification_kind", props.DefaultPrincipalsModificationKind) + d.Set("attached_database_names", props.AttachedDatabaseNames) + } + + return nil +} + +func resourceArmKustoAttachedDatabaseConfigurationDelete(d *schema.ResourceData, meta interface{}) error { + client := meta.(*clients.Client).Kusto.AttachedDatabaseConfigurationsClient + ctx, cancel := timeouts.ForDelete(meta.(*clients.Client).StopContext, d) + defer cancel() + + id, err := parse.KustoAttachedDatabaseConfigurationID(d.Id()) + if err != nil { + return err + } + + future, err := client.Delete(ctx, id.ResourceGroup, id.Cluster, id.Name) + if err != nil { + return fmt.Errorf("Error deleting Kusto Attached Database Configuration %q (Resource Group %q, Cluster %q): %+v", id.Name, id.ResourceGroup, id.Cluster, err) + } + + if err = future.WaitForCompletionRef(ctx, client.Client); err != nil { + return fmt.Errorf("Error waiting for deletion of Kusto Attached Database Configuration %q (Resource Group %q, Cluster %q): %+v", id.Name, id.ResourceGroup, id.Cluster, err) + } + + return nil +} + +func expandKustoAttachedDatabaseConfigurationProperties(d *schema.ResourceData) *kusto.AttachedDatabaseConfigurationProperties { + AttachedDatabaseConfigurationProperties := &kusto.AttachedDatabaseConfigurationProperties{} + + if clusterResourceID, ok := d.GetOk("cluster_resource_id"); ok { + AttachedDatabaseConfigurationProperties.ClusterResourceID = utils.String(clusterResourceID.(string)) + } + + if databaseName, ok := d.GetOk("database_name"); ok { + AttachedDatabaseConfigurationProperties.DatabaseName = utils.String(databaseName.(string)) + } + + if defaultPrincipalModificationKind, ok := d.GetOk("default_principal_modification_kind"); ok { + AttachedDatabaseConfigurationProperties.DefaultPrincipalsModificationKind = kusto.DefaultPrincipalsModificationKind(defaultPrincipalModificationKind.(string)) + } + + return AttachedDatabaseConfigurationProperties +} diff --git a/azurerm/internal/services/kusto/parse/kusto_attached_database_configuration.go b/azurerm/internal/services/kusto/parse/kusto_attached_database_configuration.go new file mode 100644 index 000000000000..abcf8fe0978b --- /dev/null +++ b/azurerm/internal/services/kusto/parse/kusto_attached_database_configuration.go @@ -0,0 +1,38 @@ +package parse + +import ( + "fmt" + + "github.com/terraform-providers/terraform-provider-azurerm/azurerm/helpers/azure" +) + +type KustoAttachedDatabaseConfigurationId struct { + ResourceGroup string + Cluster string + Name string +} + +func KustoAttachedDatabaseConfigurationID(input string) (*KustoAttachedDatabaseConfigurationId, error) { + id, err := azure.ParseAzureResourceID(input) + if err != nil { + return nil, fmt.Errorf("[ERROR] Unable to parse Kusto Attached Database Configuration ID %q: %+v", input, err) + } + + configuration := KustoAttachedDatabaseConfigurationId{ + ResourceGroup: id.ResourceGroup, + } + + if configuration.Cluster, err = id.PopSegment("Clusters"); err != nil { + return nil, err + } + + if configuration.Name, err = id.PopSegment("AttachedDatabaseConfigurations"); err != nil { + return nil, err + } + + if err := id.ValidateNoEmptySegments(input); err != nil { + return nil, err + } + + return &configuration, nil +} diff --git a/azurerm/internal/services/kusto/parse/kusto_attached_database_configuration_test.go b/azurerm/internal/services/kusto/parse/kusto_attached_database_configuration_test.go new file mode 100644 index 000000000000..c7c52b251d00 --- /dev/null +++ b/azurerm/internal/services/kusto/parse/kusto_attached_database_configuration_test.go @@ -0,0 +1,54 @@ +package parse + +import ( + "testing" +) + +func TestKustoAttachedDatabaseConfigurationId(t *testing.T) { + testData := []struct { + Name string + Input string + Expected *KustoAttachedDatabaseConfigurationId + }{ + { + Name: "Empty", + Input: "", + Expected: nil, + }, + { + Name: "No Cluster", + Input: "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/group1/providers/Microsoft.Kusto/AttachedDatabaseConfigurations/configuration1", + Expected: nil, + }, + { + Name: "Kusto Attached Database Configuration ID", + Input: "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/group1/providers/Microsoft.Kusto/Clusters/cluster1/AttachedDatabaseConfigurations/configuration1", + Expected: &KustoAttachedDatabaseConfigurationId{ + Name: "configuration1", + Cluster: "cluster1", + ResourceGroup: "group1", + }, + }, + } + + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Name) + + actual, err := KustoAttachedDatabaseConfigurationID(v.Input) + if err != nil { + if v.Expected == nil { + continue + } + + t.Fatalf("Expected a value but got an error: %s", err) + } + + if actual.Name != v.Expected.Name { + t.Fatalf("Expected %q but got %q for Name", v.Expected.Name, actual.Name) + } + + if actual.ResourceGroup != v.Expected.ResourceGroup { + t.Fatalf("Expected %q but got %q for Resource Group", v.Expected.ResourceGroup, actual.ResourceGroup) + } + } +} diff --git a/azurerm/internal/services/kusto/registration.go b/azurerm/internal/services/kusto/registration.go index dfded891d748..61a6d8baba6e 100644 --- a/azurerm/internal/services/kusto/registration.go +++ b/azurerm/internal/services/kusto/registration.go @@ -28,10 +28,11 @@ func (r Registration) SupportedDataSources() map[string]*schema.Resource { // SupportedResources returns the supported Resources supported by this Service func (r Registration) SupportedResources() map[string]*schema.Resource { return map[string]*schema.Resource{ - "azurerm_kusto_cluster": resourceArmKustoCluster(), - "azurerm_kusto_cluster_principal_assignment": resourceArmKustoClusterPrincipalAssignment(), - "azurerm_kusto_database": resourceArmKustoDatabase(), - "azurerm_kusto_database_principal": resourceArmKustoDatabasePrincipal(), - "azurerm_kusto_eventhub_data_connection": resourceArmKustoEventHubDataConnection(), + "azurerm_kusto_cluster": resourceArmKustoCluster(), + "azurerm_kusto_cluster_principal_assignment": resourceArmKustoClusterPrincipalAssignment(), + "azurerm_kusto_database": resourceArmKustoDatabase(), + "azurerm_kusto_database_principal": resourceArmKustoDatabasePrincipal(), + "azurerm_kusto_eventhub_data_connection": resourceArmKustoEventHubDataConnection(), + "azurerm_kusto_attached_database_configuration": resourceArmKustoAttachedDatabaseConfiguration(), } } diff --git a/azurerm/internal/services/kusto/tests/kusto_attached_database_configuration_resource_test.go b/azurerm/internal/services/kusto/tests/kusto_attached_database_configuration_resource_test.go new file mode 100644 index 000000000000..1ea469646761 --- /dev/null +++ b/azurerm/internal/services/kusto/tests/kusto_attached_database_configuration_resource_test.go @@ -0,0 +1,145 @@ +package tests + +import ( + "fmt" + "testing" + + "github.com/hashicorp/terraform-plugin-sdk/helper/resource" + "github.com/hashicorp/terraform-plugin-sdk/terraform" + "github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/acceptance" + "github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/clients" + "github.com/terraform-providers/terraform-provider-azurerm/azurerm/utils" +) + +func TestAccAzureRMKustoAttachedDatabaseConfiguration_basic(t *testing.T) { + data := acceptance.BuildTestData(t, "azurerm_kusto_attached_database_configuration", "test") + + resource.ParallelTest(t, resource.TestCase{ + PreCheck: func() { acceptance.PreCheck(t) }, + Providers: acceptance.SupportedProviders, + CheckDestroy: testCheckAzureRMKustoAttachedDatabaseConfigurationDestroy, + Steps: []resource.TestStep{ + { + Config: testAccAzureRMKustoAttachedDatabaseConfiguration_basic(data), + Check: resource.ComposeTestCheckFunc( + testCheckAzureRMKustoAttachedDatabaseConfigurationExists(data.ResourceName), + ), + }, + data.ImportStep(), + }, + }) +} + +func testAccAzureRMKustoAttachedDatabaseConfiguration_basic(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_attached_database_configuration" "configuration1" { + 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 = "*" +} +`, data.RandomInteger, data.Locations.Primary, data.RandomString, data.RandomString, data.RandomInteger, data.RandomInteger) +} + +func testCheckAzureRMKustoAttachedDatabaseConfigurationDestroy(s *terraform.State) error { + client := acceptance.AzureProvider.Meta().(*clients.Client).Kusto.AttachedDatabaseConfigurationsClient + ctx := acceptance.AzureProvider.Meta().(*clients.Client).StopContext + + for _, rs := range s.RootModule().Resources { + if rs.Type != "azurerm_kusto_attached_database_configuration" { + continue + } + + resourceGroup := rs.Primary.Attributes["resource_group_name"] + clusterName := rs.Primary.Attributes["cluster_name"] + name := rs.Primary.Attributes["name"] + + resp, err := client.Get(ctx, resourceGroup, clusterName, name) + + if err != nil { + if utils.ResponseWasNotFound(resp.Response) { + return nil + } + return err + } + + return nil + } + + return nil +} + +func testCheckAzureRMKustoAttachedDatabaseConfigurationExists(resourceName string) resource.TestCheckFunc { + return func(s *terraform.State) error { + client := acceptance.AzureProvider.Meta().(*clients.Client).Kusto.AttachedDatabaseConfigurationsClient + ctx := acceptance.AzureProvider.Meta().(*clients.Client).StopContext + + // Ensure we have enough information in state to look up in API + rs, ok := s.RootModule().Resources[resourceName] + if !ok { + return fmt.Errorf("Not found: %s", resourceName) + } + + configurationName := rs.Primary.Attributes["name"] + resourceGroup, hasResourceGroup := rs.Primary.Attributes["resource_group_name"] + if !hasResourceGroup { + return fmt.Errorf("Bad: no resource group found in state for Kusto Attached Database Configuration: %s", configurationName) + } + + clusterName, hasClusterName := rs.Primary.Attributes["cluster_name"] + if !hasClusterName { + return fmt.Errorf("Bad: no resource group found in state for Kusto Attached Database Configuration: %s", configurationName) + } + + resp, err := client.Get(ctx, resourceGroup, clusterName, configurationName) + if err != nil { + if utils.ResponseWasNotFound(resp.Response) { + return fmt.Errorf("Bad: Kusto Attached Database Configuration %q (resource group: %q, cluster: %q) does not exist", configurationName, resourceGroup, clusterName) + } + + return fmt.Errorf("Bad: Get on AttachedDatabaseConfigurationsClient: %+v", err) + } + + return nil + } +} diff --git a/website/azurerm.erb b/website/azurerm.erb index e521572cbe07..55e037951634 100644 --- a/website/azurerm.erb +++ b/website/azurerm.erb @@ -1427,6 +1427,9 @@
  • azurerm_kusto_database
  • +
  • + azurerm_kusto_attached_database_configuration +
  • azurerm_kusto_database_principal
  • diff --git a/website/docs/r/kusto_attached_database_configuration.html.markdown b/website/docs/r/kusto_attached_database_configuration.html.markdown new file mode 100644 index 000000000000..94cbdaa48f59 --- /dev/null +++ b/website/docs/r/kusto_attached_database_configuration.html.markdown @@ -0,0 +1,102 @@ +--- +subcategory: "Data Explorer" +layout: "azurerm" +page_title: "Azure Resource Manager: azurerm_kusto_attached_database_configuration" +description: |- + Manages Kusto / Data Explorer Attached Database Configuration +--- + +# azurerm_kusto_attached_database_configuration + +Manages a Kusto (also known as Azure Data Explorer) Attached Database Configuration + +## Example Usage + +```hcl +resource "azurerm_resource_group" "rg" { + name = "my-kusto-rg" + location = "East US" +} + +resource "azurerm_kusto_cluster" "follower_cluster" { + name = "cluster1" + 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" "followed_cluster" { + name = "cluster2" + 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 = "my-followed-database" + 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" "example" { + name = "configuration1" + resource_group_name = azurerm_resource_group.rg.name + location = azurerm_resource_group.rg.location + cluster_name = azurerm_kusto_cluster.follower_cluster.name + cluster_resource_id = azurerm_kusto_cluster.followed_cluster.id + database_name = "*" + default_principal_modifications_kind = "None" +} +``` + +## Argument Reference + +The following arguments are supported: + +* `name` - (Required) The name of the Kusto Attached Database Configuration to create. Changing this forces a new resource to be created. + +* `location` - (Required) Specifies the location of the Kusto Cluster for which the configuration will be created. Changing this forces a new resource to be created. + +* `resource_group_name` - (Required) Specifies the resource group of the Kusto Cluster for which the configuration will be created. Changing this forces a new resource to be created. + +* `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. + +* `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. + +* `default_principal_modification_kind` - (Optional) The default principals modification kind. Valid values are: `None` (default), `Replace` and `Union`. + +## Attributes Reference + +The following attributes are exported: + +* `id` - The Kusto Attached Database Configuration ID. + +* `attached_database_names` - The list of databases from the `cluster_resource_id` which are currently attached to the cluster. + +## Timeouts + +The `timeouts` block allows you to specify [timeouts](https://www.terraform.io/docs/configuration/resources.html#timeouts) for certain actions: + +* `create` - (Defaults to 60 minutes) Used when creating the Kusto Database. +* `update` - (Defaults to 60 minutes) Used when updating the Kusto Database. +* `read` - (Defaults to 5 minutes) Used when retrieving the Kusto Database. +* `delete` - (Defaults to 60 minutes) Used when deleting the Kusto Database. + +## Import + +Kusto Attached Database Configurations can be imported using the `resource id`, e.g. + +```shell +terraform import azurerm_kusto_attached_database_configuration.example /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/group1/providers/Microsoft.Kusto/Clusters/cluster1/AttachedDatabaseConfigurations/configuration1 +```