Skip to content

Commit ee717b6

Browse files
tombuildsstuffjrauschenbusch
authored andcommitted
updating to include hashicorp#7433
1 parent 15fce7c commit ee717b6

File tree

4 files changed

+175
-0
lines changed

4 files changed

+175
-0
lines changed

CHANGELOG.md

+5
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,12 @@
11
## 2.16.0 (Unreleased)
22

3+
DEPENDENCIES
4+
5+
* updating `github.com/Azure/go-autorest/azure/cli` to `v0.3.1` [GH-7433]
6+
37
ENHANCEMENTS
48

9+
* authentication: Azure CLI - support for access tokens in custom directories [GH-7433]
510
* `azurerm_app_service_environment` - support a value of `Web, Publishing` for the `internal_load_balancing_mode` property [GH-7346]
611
* `azurerm_kusto_cluster` - support for the `identity` block [GH-7367]
712
* `azurerm_kusto_cluster` - support for `virtual_network_configuration` block [GH-7369]

azurerm/internal/services/kusto/kusto_cluster_resource.go

+91
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,31 @@ func resourceArmKustoCluster() *schema.Resource {
110110
Optional: true,
111111
},
112112

113+
"key_vault": {
114+
Type: schema.TypeList,
115+
Optional: true,
116+
MaxItems: 1,
117+
Elem: &schema.Resource{
118+
Schema: map[string]*schema.Schema{
119+
"key_name": {
120+
Type: schema.TypeString,
121+
Required: true,
122+
ValidateFunc: azure.ValidateKeyVaultChildName,
123+
},
124+
"key_version": {
125+
Type: schema.TypeString,
126+
Required: true,
127+
ValidateFunc: validation.StringIsNotEmpty,
128+
},
129+
"key_vault_uri": {
130+
Type: schema.TypeString,
131+
Required: true,
132+
ValidateFunc: validation.IsURLWithHTTPS,
133+
},
134+
},
135+
},
136+
},
137+
113138
"virtual_network_configuration": {
114139
Type: schema.TypeList,
115140
Optional: true,
@@ -232,6 +257,25 @@ func resourceArmKustoClusterCreateUpdate(d *schema.ResourceData, meta interface{
232257

233258
d.SetId(*resp.ID)
234259

260+
if v, ok := d.GetOk("key_vault"); ok {
261+
keyVaultProperties := expandKustoClusterKeyVault(v.([]interface{}))
262+
263+
clusterUpdate := kusto.ClusterUpdate{
264+
ClusterProperties: &kusto.ClusterProperties{
265+
KeyVaultProperties: keyVaultProperties,
266+
},
267+
}
268+
269+
future, err := client.Update(ctx, resourceGroup, name, clusterUpdate)
270+
if err != nil {
271+
return fmt.Errorf("Error creating or updating Kusto Cluster %q (Resource Group %q): %+v", name, resourceGroup, err)
272+
}
273+
274+
if err = future.WaitForCompletionRef(ctx, client.Client); err != nil {
275+
return fmt.Errorf("Error waiting for completion of Kusto Cluster %q (Resource Group %q): %+v", name, resourceGroup, err)
276+
}
277+
}
278+
235279
return resourceArmKustoClusterRead(d, meta)
236280
}
237281

@@ -279,6 +323,7 @@ func resourceArmKustoClusterRead(d *schema.ResourceData, meta interface{}) error
279323
d.Set("enable_streaming_ingest", clusterProperties.EnableStreamingIngest)
280324
d.Set("enable_purge", clusterProperties.EnablePurge)
281325
d.Set("virtual_network_configuration", flatteKustoClusterVNET(clusterProperties.VirtualNetworkConfiguration))
326+
d.Set("key_vault", flatteKustoClusterKeyVault(clusterProperties.KeyVaultProperties))
282327
d.Set("uri", clusterProperties.URI)
283328
d.Set("data_ingestion_uri", clusterProperties.DataIngestionURI)
284329
}
@@ -366,6 +411,23 @@ func expandKustoClusterVNET(input []interface{}) *kusto.VirtualNetworkConfigurat
366411
}
367412
}
368413

414+
func expandKustoClusterKeyVault(input []interface{}) *kusto.KeyVaultProperties {
415+
if len(input) == 0 && input[0] != nil {
416+
return nil
417+
}
418+
419+
keyVault := input[0].(map[string]interface{})
420+
keyName := keyVault["key_name"].(string)
421+
keyVersion := keyVault["key_version"].(string)
422+
uri := keyVault["key_vault_uri"].(string)
423+
424+
return &kusto.KeyVaultProperties{
425+
KeyName: &keyName,
426+
KeyVersion: &keyVersion,
427+
KeyVaultURI: &uri,
428+
}
429+
}
430+
369431
func flattenKustoClusterSku(sku *kusto.AzureSku) []interface{} {
370432
if sku == nil {
371433
return []interface{}{}
@@ -410,3 +472,32 @@ func flatteKustoClusterVNET(vnet *kusto.VirtualNetworkConfiguration) []interface
410472

411473
return []interface{}{output}
412474
}
475+
476+
func flatteKustoClusterKeyVault(keyVault *kusto.KeyVaultProperties) []interface{} {
477+
if keyVault == nil {
478+
return []interface{}{}
479+
}
480+
481+
keyName := ""
482+
if keyVault.KeyName != nil {
483+
keyName = *keyVault.KeyName
484+
}
485+
486+
keyVersion := ""
487+
if keyVault.KeyVersion != nil {
488+
keyVersion = *keyVault.KeyVersion
489+
}
490+
491+
keyVaultURI := ""
492+
if keyVault.KeyVaultURI != nil {
493+
keyVaultURI = *keyVault.KeyVaultURI
494+
}
495+
496+
output := map[string]interface{}{
497+
"key_name": keyName,
498+
"key_version": keyVersion,
499+
"key_vault_uri": keyVaultURI,
500+
}
501+
502+
return []interface{}{output}
503+
}

azurerm/internal/services/kusto/tests/kusto_cluster_resource_test.go

+67
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,29 @@ func TestAccAzureRMKustoCluster_zones(t *testing.T) {
150150
})
151151
}
152152

153+
func TestAccAzureRMKustoCluster_keyVault(t *testing.T) {
154+
data := acceptance.BuildTestData(t, "azurerm_kusto_cluster", "test")
155+
156+
resource.ParallelTest(t, resource.TestCase{
157+
PreCheck: func() { acceptance.PreCheck(t) },
158+
Providers: acceptance.SupportedProviders,
159+
CheckDestroy: testCheckAzureRMKustoClusterDestroy,
160+
Steps: []resource.TestStep{
161+
{
162+
Config: testAccAzureRMKustoCluster_keyVault(data),
163+
Check: resource.ComposeTestCheckFunc(
164+
testCheckAzureRMKustoClusterExists(data.ResourceName),
165+
resource.TestCheckResourceAttr(data.ResourceName, "key_vault.#", "1"),
166+
resource.TestCheckResourceAttr(data.ResourceName, "key_vault.0.key_name", ""),
167+
resource.TestCheckResourceAttr(data.ResourceName, "key_vault.0.key_version", ""),
168+
resource.TestCheckResourceAttrSet(data.ResourceName, "key_vault.0.key_vault_uri"),
169+
),
170+
},
171+
data.ImportStep(),
172+
},
173+
})
174+
}
175+
153176
func TestAccAzureRMKustoCluster_identitySystemAssigned(t *testing.T) {
154177
data := acceptance.BuildTestData(t, "azurerm_kusto_cluster", "test")
155178

@@ -381,6 +404,50 @@ resource "azurerm_kusto_cluster" "test" {
381404
`, data.RandomInteger, data.Locations.Primary, data.RandomString)
382405
}
383406

407+
func testAccAzureRMKustoCluster_keyVault(data acceptance.TestData) string {
408+
return fmt.Sprintf(`
409+
provider "azurerm" {
410+
features {}
411+
}
412+
413+
data "azurerm_client_config" "current" {}
414+
415+
resource "azurerm_resource_group" "test" {
416+
name = "acctestRG-%d"
417+
location = "%s"
418+
}
419+
420+
resource "azurerm_key_vault" "test" {
421+
name = "acctestkc%s-vault"
422+
location = azurerm_resource_group.test.location
423+
resource_group_name = azurerm_resource_group.test.name
424+
tenant_id = data.azurerm_client_config.current.tenant_id
425+
sku_name = "standard"
426+
}
427+
428+
resource "azurerm_kusto_cluster" "test" {
429+
name = "acctestkc%s"
430+
location = azurerm_resource_group.test.location
431+
resource_group_name = azurerm_resource_group.test.name
432+
433+
sku {
434+
name = "Dev(No SLA)_Standard_D11_v2"
435+
capacity = 1
436+
}
437+
438+
identity {
439+
type = "SystemAssigned"
440+
}
441+
442+
key_vault {
443+
key_name = "acctestkc%s"
444+
key_version = "1"
445+
key_vault_uri = azurerm_key_vault.test.vault_uri
446+
}
447+
}
448+
`, data.RandomInteger, data.Locations.Primary, data.RandomString, data.RandomString, data.RandomString)
449+
}
450+
384451
func testCheckAzureRMKustoClusterDestroy(s *terraform.State) error {
385452
client := acceptance.AzureProvider.Meta().(*clients.Client).Kusto.ClustersClient
386453
ctx := acceptance.AzureProvider.Meta().(*clients.Client).StopContext

website/docs/r/kusto_cluster.html.markdown

+12
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,8 @@ The following arguments are supported:
5656

5757
* `virtual_network_configuration`- (Optional) A `virtual_network_configuration` block as defined below.
5858

59+
* `key_vault` - (Optional) A `key_vault` block as defined below.
60+
5961
* `tags` - (Optional) A mapping of tags to assign to the resource.
6062

6163
* `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.
@@ -92,6 +94,16 @@ An `identity` block supports the following:
9294

9395
~> **NOTE:** When `type` is set to `SystemAssigned`, the Principal ID can be retrieved after the cluster has been created. More details are available below. See [documentation](https://docs.microsoft.com/en-us/azure/active-directory/managed-service-identity/overview) for additional information.
9496

97+
---
98+
99+
A `key_vault` block supports the following:
100+
101+
* `key_name` - (Required) The name of the key vault key.
102+
103+
* `key_version` - (Required) The version of the key vault key.
104+
105+
* `uri` - (Required) The Uri of the key vault.
106+
95107
## Attributes Reference
96108

97109
The following attributes are exported:

0 commit comments

Comments
 (0)