Skip to content

Commit

Permalink
Fix for azurerm_kubernetes_cluster InvalidLoadbalancerProfile
Browse files Browse the repository at this point in the history
  • Loading branch information
Aris van Ommeren committed Apr 19, 2020
1 parent b7ae3e2 commit aa37bd2
Showing 1 changed file with 7 additions and 2 deletions.
Expand Up @@ -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
}
Expand Down Expand Up @@ -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
}
Expand All @@ -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}
Expand Down

0 comments on commit aa37bd2

Please sign in to comment.