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 - support for enable_disk_encryption and enable_streaming_ingest #5855

Merged
merged 9 commits into from
Mar 2, 2020
17 changes: 16 additions & 1 deletion azurerm/internal/services/kusto/resource_arm_kusto_cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,16 @@ func resourceArmKustoCluster() *schema.Resource {
},
},

"enable_disk_encryption": {
Type: schema.TypeBool,
Optional: true,
},

"enable_streaming_ingest": {
Type: schema.TypeBool,
Optional: true,
},

"uri": {
Type: schema.TypeString,
Computed: true,
Expand Down Expand Up @@ -128,7 +138,10 @@ func resourceArmKustoClusterCreateUpdate(d *schema.ResourceData, meta interface{
return err
}

clusterProperties := kusto.ClusterProperties{}
clusterProperties := kusto.ClusterProperties{
EnableDiskEncryption: utils.Bool(d.Get("enable_disk_encryption").(bool)),
EnableStreamingIngest: utils.Bool(d.Get("enable_streaming_ingest").(bool)),
}

t := d.Get("tags").(map[string]interface{})

Expand Down Expand Up @@ -198,6 +211,8 @@ func resourceArmKustoClusterRead(d *schema.ResourceData, meta interface{}) error
}

if clusterProperties := clusterResponse.ClusterProperties; clusterProperties != nil {
d.Set("enable_disk_encryption", clusterProperties.EnableDiskEncryption)
d.Set("enable_streaming_ingest", clusterProperties.EnableStreamingIngest)
d.Set("uri", clusterProperties.URI)
d.Set("data_ingestion_uri", clusterProperties.DataIngestionURI)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,45 @@ func TestAccAzureRMKustoCluster_basic(t *testing.T) {
})
}

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we have a complete test here as described before

func TestAccAzureRMKustoCluster_update(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_basic(data),
Check: resource.ComposeTestCheckFunc(
testCheckAzureRMKustoClusterExists(data.ResourceName),
resource.TestCheckResourceAttr(data.ResourceName, "enable_disk_encryption", "false"),
resource.TestCheckResourceAttr(data.ResourceName, "enable_streaming_ingest", "false"),
),
},
data.ImportStep(),
{
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could wedo an import check here

Config: testAccAzureRMKustoCluster_update(data),
Check: resource.ComposeTestCheckFunc(
testCheckAzureRMKustoClusterExists(data.ResourceName),
resource.TestCheckResourceAttr(data.ResourceName, "enable_disk_encryption", "true"),
resource.TestCheckResourceAttr(data.ResourceName, "enable_streaming_ingest", "true"),
),
},
data.ImportStep(),
{
Config: testAccAzureRMKustoCluster_basic(data),
Check: resource.ComposeTestCheckFunc(
testCheckAzureRMKustoClusterExists(data.ResourceName),
resource.TestCheckResourceAttr(data.ResourceName, "enable_disk_encryption", "false"),
resource.TestCheckResourceAttr(data.ResourceName, "enable_streaming_ingest", "false"),
),
},
data.ImportStep(),
},
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And then here go back to basic

})
}

func TestAccAzureRMKustoCluster_withTags(t *testing.T) {
data := acceptance.BuildTestData(t, "azurerm_kusto_cluster", "test")

Expand Down Expand Up @@ -192,6 +231,32 @@ resource "azurerm_kusto_cluster" "test" {
`, data.RandomInteger, data.Locations.Primary, data.RandomString)
}

func testAccAzureRMKustoCluster_update(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
enable_disk_encryption = true
enable_streaming_ingest = true

sku {
name = "Dev(No SLA)_Standard_D11_v2"
capacity = 1
}
}
`, data.RandomInteger, data.Locations.Primary, data.RandomString)
}

func testCheckAzureRMKustoClusterDestroy(s *terraform.State) error {
client := acceptance.AzureProvider.Meta().(*clients.Client).Kusto.ClustersClient
ctx := acceptance.AzureProvider.Meta().(*clients.Client).StopContext
Expand Down
4 changes: 4 additions & 0 deletions website/docs/r/kusto_cluster.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,10 @@ The following arguments are supported:

* `sku` - (Required) A `sku` block as defined below.

* `enable_disk_encryption` - (Optional) Specifies if the cluster's disks are encrypted.

* `enable_streaming_ingest` - (Optional) Specifies if the streaming ingest is enabled.

* `tags` - (Optional) A mapping of tags to assign to the resource.

---
Expand Down