Skip to content

Commit

Permalink
Fix the virtual_network_configuration block to ensure it functions …
Browse files Browse the repository at this point in the history
…as intended.
  • Loading branch information
liuwuliuyun committed Dec 10, 2024
1 parent 0f24868 commit 7ad7b9d
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 9 deletions.
23 changes: 20 additions & 3 deletions internal/services/kusto/kusto_cluster_resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
package kusto

import (
"context"
"fmt"
"log"
"strings"
Expand Down Expand Up @@ -149,19 +150,16 @@ func resourceKustoCluster() *pluginsdk.Resource {
"subnet_id": {
Type: pluginsdk.TypeString,
Required: true,
ForceNew: true,
ValidateFunc: commonids.ValidateSubnetID,
},
"engine_public_ip_id": {
Type: pluginsdk.TypeString,
Required: true,
ForceNew: true,
ValidateFunc: commonids.ValidatePublicIPAddressID,
},
"data_management_public_ip_id": {
Type: pluginsdk.TypeString,
Required: true,
ForceNew: true,
ValidateFunc: commonids.ValidatePublicIPAddressID,
},
},
Expand Down Expand Up @@ -250,6 +248,25 @@ func resourceKustoCluster() *pluginsdk.Resource {

"tags": commonschema.Tags(),
},

CustomizeDiff: pluginsdk.CustomDiffWithAll(
pluginsdk.CustomizeDiffShim(func(ctx context.Context, d *pluginsdk.ResourceDiff, v interface{}) error {
oldSubnetId, newSubnetId := d.GetChange("virtual_network_configuration.0.subnet_id")
if oldSubnetId != "" && newSubnetId != "" && oldSubnetId != newSubnetId {
return fmt.Errorf("changing `virtual_network_configuration.0.subnet_id` is not supported")
}
oldPublicIpId, newPublicIpId := d.GetChange("virtual_network_configuration.0.engine_public_ip_id")
if oldPublicIpId != "" && newPublicIpId != "" && oldPublicIpId != newPublicIpId {
return fmt.Errorf("changing `virtual_network_configuration.0.engine_public_ip_id` is not supported")
}
oldDataManagementPublicIpId, newDataManagementPublicIpId := d.GetChange("virtual_network_configuration.0.data_management_public_ip_id")
if oldDataManagementPublicIpId != "" && newDataManagementPublicIpId != "" && oldDataManagementPublicIpId != newDataManagementPublicIpId {
return fmt.Errorf("changing `virtual_network_configuration.0.data_management_public_ip_id` is not supported")
}

return nil
}),
),
}

return resource
Expand Down
1 change: 0 additions & 1 deletion internal/services/kusto/kusto_cluster_resource_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1055,7 +1055,6 @@ resource "azurerm_kusto_cluster" "test" {
name = "Dev(No SLA)_Standard_D11_v2"
capacity = 1
}
public_network_access_enabled = false
depends_on = [
azurerm_subnet_route_table_association.test,
azurerm_subnet_network_security_group_association.test,
Expand Down
10 changes: 5 additions & 5 deletions website/docs/r/kusto_cluster.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,6 @@ The following arguments are supported:

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

~> **NOTE:** Currently removing `virtual_network_configuration` sets the `virtual_network_configuration` to `Disabled` state. But any changes to `virtual_network_configuration` in `Disabled` state forces a new resource to be created.

* `language_extensions` - (Optional) An list of `language_extensions` to enable. Valid values are: `PYTHON`, `PYTHON_3.10.8` and `R`. `PYTHON` is used to specify Python 3.6.5 image and `PYTHON_3.10.8` is used to specify Python 3.10.8 image. Note that `PYTHON_3.10.8` is only available in skus which support nested virtualization.

~> **NOTE:** In `v4.0.0` and later version of the AzureRM Provider, `language_extensions` will be changed to a list of `language_extension` block. In each block, `name` and `image` are required. `name` is the name of the language extension, possible values are `PYTHON`, `R`. `image` is the image of the language extension, possible values are `Python3_6_5`, `Python3_10_8` and `R`.
Expand Down Expand Up @@ -100,11 +98,13 @@ A `sku` block supports the following:

A `virtual_network_configuration` block supports the following:

* `subnet_id` - (Required) The subnet resource id.
~> **NOTE:** Currently removing `virtual_network_configuration` sets the `virtual_network_configuration` to `Disabled` state. Restoring the `virtual_network_configuration` with the same configuration will set the `virtual_network_configuration` to `Enabled` state.

* `subnet_id` - (Required) The subnet resource id. This property could not be changed after the cluster is created.

* `engine_public_ip_id` - (Required) Engine service's public IP address resource id.
* `engine_public_ip_id` - (Required) Engine service's public IP address resource id. This property could not be changed after the cluster is created.

* `data_management_public_ip_id` - (Required) Data management's service public IP address resource id.
* `data_management_public_ip_id` - (Required) Data management's service public IP address resource id. This property could not be changed after the cluster is created.

---

Expand Down

0 comments on commit 7ad7b9d

Please sign in to comment.