From 4ceb32e8d9dc77f42b42af08b33beae6291f91e0 Mon Sep 17 00:00:00 2001 From: Jochen Rauschenbusch Date: Sun, 24 May 2020 12:56:28 +0200 Subject: [PATCH 1/3] Support for Kusto Cluster Availability Zones --- .../services/kusto/kusto_cluster_resource.go | 9 ++++ .../tests/kusto_cluster_resource_test.go | 46 +++++++++++++++++++ website/docs/r/kusto_cluster.html.markdown | 2 + 3 files changed, 57 insertions(+) diff --git a/azurerm/internal/services/kusto/kusto_cluster_resource.go b/azurerm/internal/services/kusto/kusto_cluster_resource.go index bcb69cdb468c..1c09a821c298 100644 --- a/azurerm/internal/services/kusto/kusto_cluster_resource.go +++ b/azurerm/internal/services/kusto/kusto_cluster_resource.go @@ -93,6 +93,8 @@ func resourceArmKustoCluster() *schema.Resource { }, }, + "zones": azure.SchemaZones(), + "enable_disk_encryption": { Type: schema.TypeBool, Optional: true, @@ -153,6 +155,8 @@ func resourceArmKustoClusterCreateUpdate(d *schema.ResourceData, meta interface{ return err } + zones := azure.ExpandZones(d.Get("zones").([]interface{})) + clusterProperties := kusto.ClusterProperties{ EnableDiskEncryption: utils.Bool(d.Get("enable_disk_encryption").(bool)), EnableStreamingIngest: utils.Bool(d.Get("enable_streaming_ingest").(bool)), @@ -165,6 +169,7 @@ func resourceArmKustoClusterCreateUpdate(d *schema.ResourceData, meta interface{ Name: &name, Location: &location, Sku: sku, + Zones: zones, ClusterProperties: &clusterProperties, Tags: tags.Expand(t), } @@ -223,6 +228,10 @@ func resourceArmKustoClusterRead(d *schema.ResourceData, meta interface{}) error return fmt.Errorf("Error setting `sku`: %+v", err) } + if err := d.Set("zones", azure.FlattenZones(clusterResponse.Zones)); err != nil { + return fmt.Errorf("Error setting `zones`: %+v", err) + } + if clusterProperties := clusterResponse.ClusterProperties; clusterProperties != nil { d.Set("enable_disk_encryption", clusterProperties.EnableDiskEncryption) d.Set("enable_streaming_ingest", clusterProperties.EnableStreamingIngest) diff --git a/azurerm/internal/services/kusto/tests/kusto_cluster_resource_test.go b/azurerm/internal/services/kusto/tests/kusto_cluster_resource_test.go index ff6009d0ece4..5f9205b94e8d 100644 --- a/azurerm/internal/services/kusto/tests/kusto_cluster_resource_test.go +++ b/azurerm/internal/services/kusto/tests/kusto_cluster_resource_test.go @@ -129,6 +129,26 @@ func TestAccAzureRMKustoCluster_sku(t *testing.T) { }) } +func TestAccAzureRMKustoCluster_zones(t *testing.T) { + data := acceptance.BuildTestData(t, "azurerm_kusto_cluster", "test") + + resource.ParallelTest(t, resource.TestCase{ + PreCheck: func() { acceptance.PreCheck(t) }, + Providers: acceptance.SupportedProviders, + CheckDestroy: testCheckAzureRMKustoClusterDestroy, + Steps: []resource.TestStep{ + { + Config: testAccAzureRMKustoCluster_withZones(data), + Check: resource.ComposeTestCheckFunc( + testCheckAzureRMKustoClusterExists(data.ResourceName), + resource.TestCheckResourceAttr(data.ResourceName, "zones.#", "1"), + resource.TestCheckResourceAttr(data.ResourceName, "zones.0", "1"), + ), + }, + }, + }) +} + func testAccAzureRMKustoCluster_basic(data acceptance.TestData) string { return fmt.Sprintf(` provider "azurerm" { @@ -234,6 +254,32 @@ resource "azurerm_kusto_cluster" "test" { `, data.RandomInteger, data.Locations.Primary, data.RandomString) } +func testAccAzureRMKustoCluster_withZones(data acceptance.TestData) string { + return fmt.Sprintf(` +provider "azurerm" { + features {} +} + +resource "azurerm_resource_group" "test" { + name = "acctestRG-%d" + location = "%s" +} + +resource "azurerm_kusto_cluster" "test" { + name = "acctestkc%s" + location = azurerm_resource_group.test.location + resource_group_name = azurerm_resource_group.test.name + + sku { + name = "Dev(No SLA)_Standard_D11_v2" + capacity = 1 + } + + zones = ["1"] +} +`, data.RandomInteger, data.Locations.Primary, data.RandomString) +} + func testAccAzureRMKustoCluster_update(data acceptance.TestData) string { return fmt.Sprintf(` provider "azurerm" { diff --git a/website/docs/r/kusto_cluster.html.markdown b/website/docs/r/kusto_cluster.html.markdown index 91a0b95c8701..11d6bed499da 100644 --- a/website/docs/r/kusto_cluster.html.markdown +++ b/website/docs/r/kusto_cluster.html.markdown @@ -46,6 +46,8 @@ The following arguments are supported: * `sku` - (Required) A `sku` block as defined below. +* `zones` - (Optional) A list of Availability Zones in which the cluster instances should be created in. Changing this forces a new resource to be created. + * `enable_disk_encryption` - (Optional) Specifies if the cluster's disks are encrypted. * `enable_streaming_ingest` - (Optional) Specifies if the streaming ingest is enabled. From 7b1694a6d752e0ae77c8716c15d302aefe6b4888 Mon Sep 17 00:00:00 2001 From: kt Date: Tue, 23 Jun 2020 15:47:19 -0700 Subject: [PATCH 2/3] move zones to end of schema with tags --- azurerm/internal/services/kusto/kusto_cluster_resource.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/azurerm/internal/services/kusto/kusto_cluster_resource.go b/azurerm/internal/services/kusto/kusto_cluster_resource.go index 1c09a821c298..7dd944a2127a 100644 --- a/azurerm/internal/services/kusto/kusto_cluster_resource.go +++ b/azurerm/internal/services/kusto/kusto_cluster_resource.go @@ -93,8 +93,6 @@ func resourceArmKustoCluster() *schema.Resource { }, }, - "zones": azure.SchemaZones(), - "enable_disk_encryption": { Type: schema.TypeBool, Optional: true, @@ -120,6 +118,8 @@ func resourceArmKustoCluster() *schema.Resource { Computed: true, }, + "zones": azure.SchemaZones(), + "tags": tags.Schema(), }, } From b82c2ced6d234ac0971f2dee60893d235ea4038d Mon Sep 17 00:00:00 2001 From: kt Date: Tue, 23 Jun 2020 20:59:56 -0700 Subject: [PATCH 3/3] Update kusto_cluster.html.markdown --- website/docs/r/kusto_cluster.html.markdown | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/website/docs/r/kusto_cluster.html.markdown b/website/docs/r/kusto_cluster.html.markdown index 1b579f414c8f..2ac81770333c 100644 --- a/website/docs/r/kusto_cluster.html.markdown +++ b/website/docs/r/kusto_cluster.html.markdown @@ -46,8 +46,6 @@ The following arguments are supported: * `sku` - (Required) A `sku` block as defined below. -* `zones` - (Optional) A list of Availability Zones in which the cluster instances should be created in. Changing this forces a new resource to be created. - * `identity` - (Optional) A identity block. * `enable_disk_encryption` - (Optional) Specifies if the cluster's disks are encrypted. @@ -60,6 +58,8 @@ The following arguments are supported: * `tags` - (Optional) A mapping of tags to assign to the resource. +* `zones` - (Optional) A list of Availability Zones in which the cluster instances should be created in. Changing this forces a new resource to be created. + --- A `sku` block supports the following: