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 trusted_external_tenants #7374

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 31 additions & 0 deletions azurerm/helpers/azure/kusto.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"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/suppress"
"github.com/terraform-providers/terraform-provider-azurerm/azurerm/utils"
)

func SchemaKustoIdentity() *schema.Schema {
Expand Down Expand Up @@ -89,3 +90,33 @@ func FlattenKustoIdentity(input *kusto.Identity) []interface{} {
},
}
}

func ExpandKustoClusterTrustedExternalTenants(input []interface{}) *[]kusto.TrustedExternalTenant {
output := make([]kusto.TrustedExternalTenant, 0)

for _, v := range input {
output = append(output, kusto.TrustedExternalTenant{
Value: utils.String(v.(string)),
})
}

return &output
}

func FlattenKustoClusterTrustedExternalTenants(input *[]kusto.TrustedExternalTenant) []interface{} {
if input == nil {
return []interface{}{}
}

output := make([]interface{}, 0)

for _, v := range *input {
if v.Value == nil {
continue
}

output = append(output, *v.Value)
}

return output
}
17 changes: 17 additions & 0 deletions azurerm/internal/services/kusto/kusto_cluster_resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,17 @@ func resourceArmKustoCluster() *schema.Resource {
},
},

"trusted_external_tenants": {
Type: schema.TypeList,
Optional: true,
Computed: true,
ConfigMode: schema.SchemaConfigModeAttr,
Elem: &schema.Schema{
Type: schema.TypeString,
ValidateFunc: validation.Any(validation.IsUUID, validation.StringIsEmpty),
},
},

"optimized_auto_scale": {
Type: schema.TypeList,
Optional: true,
Expand Down Expand Up @@ -247,6 +258,11 @@ func resourceArmKustoClusterCreateUpdate(d *schema.ResourceData, meta interface{
clusterProperties.VirtualNetworkConfiguration = vnet
}

if v, ok := d.GetOk("trusted_external_tenants"); ok {
trustedExternalTenants := azure.ExpandKustoClusterTrustedExternalTenants(v.([]interface{}))
clusterProperties.TrustedExternalTenants = trustedExternalTenants
}

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

kustoCluster := kusto.Cluster{
Expand Down Expand Up @@ -370,6 +386,7 @@ func resourceArmKustoClusterRead(d *schema.ResourceData, meta interface{}) error
}

if clusterProperties := clusterResponse.ClusterProperties; clusterProperties != nil {
d.Set("trusted_external_tenants", azure.FlattenKustoClusterTrustedExternalTenants(clusterProperties.TrustedExternalTenants))
d.Set("enable_disk_encryption", clusterProperties.EnableDiskEncryption)
d.Set("enable_streaming_ingest", clusterProperties.EnableStreamingIngest)
d.Set("enable_purge", clusterProperties.EnablePurge)
Expand Down
2 changes: 2 additions & 0 deletions website/docs/r/kusto_cluster.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,8 @@ The following arguments are supported:

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

* `trusted_external_tenants` - (Optional) Specifies a list of tenant IDs that are trusted by the cluster.

* `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.

---
Expand Down