From aa37bd2c6ba2fa6ad9851917b1a7c314be40f89e Mon Sep 17 00:00:00 2001 From: Aris van Ommeren Date: Sun, 19 Apr 2020 15:56:26 +0200 Subject: [PATCH 1/2] Fix for azurerm_kubernetes_cluster InvalidLoadbalancerProfile --- .../containers/resource_arm_kubernetes_cluster.go | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/azurerm/internal/services/containers/resource_arm_kubernetes_cluster.go b/azurerm/internal/services/containers/resource_arm_kubernetes_cluster.go index bf1b4312903f..8d297911c291 100644 --- a/azurerm/internal/services/containers/resource_arm_kubernetes_cluster.go +++ b/azurerm/internal/services/containers/resource_arm_kubernetes_cluster.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} From f58fa82c39b76b10ed089d86b4f237937f2a1351 Mon Sep 17 00:00:00 2001 From: Aris van Ommeren Date: Sun, 19 Apr 2020 18:25:31 +0200 Subject: [PATCH 2/2] Test enhanced for extra coverage --- .../tests/resource_arm_kubernetes_cluster_scaling_test.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/azurerm/internal/services/containers/tests/resource_arm_kubernetes_cluster_scaling_test.go b/azurerm/internal/services/containers/tests/resource_arm_kubernetes_cluster_scaling_test.go index 0969b174dc76..fac436260526 100644 --- a/azurerm/internal/services/containers/tests/resource_arm_kubernetes_cluster_scaling_test.go +++ b/azurerm/internal/services/containers/tests/resource_arm_kubernetes_cluster_scaling_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) }