diff --git a/azurerm/internal/services/containers/kubernetes_cluster_resource.go b/azurerm/internal/services/containers/kubernetes_cluster_resource.go index bf1b4312903f..8d297911c291 100644 --- a/azurerm/internal/services/containers/kubernetes_cluster_resource.go +++ b/azurerm/internal/services/containers/kubernetes_cluster_resource.go @@ -575,7 +575,7 @@ func resourceArmKubernetesClusterCreate(d *schema.ResourceData, meta interface{} } networkProfileRaw := d.Get("network_profile").([]interface{}) - networkProfile, err := expandKubernetesClusterNetworkProfile(networkProfileRaw, true, true, true) + networkProfile, err := expandKubernetesClusterNetworkProfile(networkProfileRaw, false, false, false) if err != nil { return err } @@ -1266,7 +1266,7 @@ func expandKubernetesClusterNetworkProfile(input []interface{}, changeManagedIps return &networkProfile, nil } -func expandLoadBalancerProfile(d []interface{}, loadBalancerType string, allowToSetIpCount bool, allowToSetIpPrefixes bool, allowToSetOutboundIp bool) (*containerservice.ManagedClusterLoadBalancerProfile, error) { +func expandLoadBalancerProfile(d []interface{}, loadBalancerType string, ipCountChanges bool, ipPrefixesChanges bool, outboundIpChanges bool) (*containerservice.ManagedClusterLoadBalancerProfile, error) { if len(d) == 0 || d[0] == nil { return nil, nil } @@ -1281,6 +1281,11 @@ func expandLoadBalancerProfile(d []interface{}, loadBalancerType string, allowTo var outboundIpPrefixes *containerservice.ManagedClusterLoadBalancerProfileOutboundIPPrefixes var outboundIps *containerservice.ManagedClusterLoadBalancerProfileOutboundIPs + noChangesForLoadBalancerIps := !ipCountChanges && !ipPrefixesChanges && !outboundIpChanges + allowToSetIpCount := ipCountChanges || noChangesForLoadBalancerIps + allowToSetIpPrefixes := ipPrefixesChanges || noChangesForLoadBalancerIps + allowToSetOutboundIp := outboundIpChanges || noChangesForLoadBalancerIps + if ipCount := config["managed_outbound_ip_count"]; ipCount != nil && allowToSetIpCount { if c := int32(ipCount.(int)); c > 0 { managedOutboundIps = &containerservice.ManagedClusterLoadBalancerProfileManagedOutboundIPs{Count: &c} diff --git a/azurerm/internal/services/containers/tests/kubernetes_cluster_scaling_resource_test.go b/azurerm/internal/services/containers/tests/kubernetes_cluster_scaling_resource_test.go index 0969b174dc76..fac436260526 100644 --- a/azurerm/internal/services/containers/tests/kubernetes_cluster_scaling_resource_test.go +++ b/azurerm/internal/services/containers/tests/kubernetes_cluster_scaling_resource_test.go @@ -212,6 +212,11 @@ resource "azurerm_kubernetes_cluster" "test" { identity { type = "SystemAssigned" } + + network_profile { + network_plugin = "kubenet" + load_balancer_sku = "standard" + } } `, data.RandomInteger, data.Locations.Primary, data.RandomInteger, data.RandomInteger, numberOfAgents) }