Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

azurerm_kusto_cluster - supoport for zones #7373

Merged
merged 5 commits into from Jun 24, 2020
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
9 changes: 9 additions & 0 deletions azurerm/internal/services/kusto/kusto_cluster_resource.go
Expand Up @@ -118,6 +118,8 @@ func resourceArmKustoCluster() *schema.Resource {
Computed: true,
},

"zones": azure.SchemaZones(),

"tags": tags.Schema(),
},
}
Expand Down Expand Up @@ -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)),
Expand All @@ -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),
}
Expand Down Expand Up @@ -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)
Expand Down
Expand Up @@ -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" {
Expand Down Expand Up @@ -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" {
Expand Down
2 changes: 2 additions & 0 deletions website/docs/r/kusto_cluster.html.markdown
Expand Up @@ -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.
Expand Down