From a6d6e81f52bd0e0a7670fe579a3294e0aced7eb7 Mon Sep 17 00:00:00 2001 From: ms-henglu <79895375+ms-henglu@users.noreply.github.com> Date: Wed, 21 Jul 2021 08:28:06 +0800 Subject: [PATCH] fix crash when create compute cluster without specifying subnetId (#12658) * fix crash when create machine learning compute cluster without specifying subnetId * add nil-check on props --- .../machine_learning_compute_cluster_resource.go | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/azurerm/internal/services/machinelearning/machine_learning_compute_cluster_resource.go b/azurerm/internal/services/machinelearning/machine_learning_compute_cluster_resource.go index 706e0c98acfc..44de7ed68355 100644 --- a/azurerm/internal/services/machinelearning/machine_learning_compute_cluster_resource.go +++ b/azurerm/internal/services/machinelearning/machine_learning_compute_cluster_resource.go @@ -240,10 +240,14 @@ func resourceComputeClusterRead(d *pluginsdk.ResourceData, meta interface{}) err return fmt.Errorf("compute resource %s is not an Aml Compute cluster", id.ComputeName) } - d.Set("vm_size", computeCluster.Properties.VMSize) - d.Set("vm_priority", computeCluster.Properties.VMPriority) - d.Set("scale_settings", flattenScaleSettings(computeCluster.Properties.ScaleSettings)) - d.Set("subnet_resource_id", computeCluster.Properties.Subnet.ID) + if props := computeCluster.Properties; props != nil { + d.Set("vm_size", props.VMSize) + d.Set("vm_priority", props.VMPriority) + d.Set("scale_settings", flattenScaleSettings(props.ScaleSettings)) + if props.Subnet != nil { + d.Set("subnet_resource_id", props.Subnet.ID) + } + } if location := computeResource.Location; location != nil { d.Set("location", azure.NormalizeLocation(*location))