Skip to content

Commit

Permalink
Bug: azurerm_kubernetes_cluster errors out with InvalidLoadbalancerPr…
Browse files Browse the repository at this point in the history
…ofile on changes (#6534)

Fixes #6525
  • Loading branch information
aristosvo committed May 12, 2020
1 parent 2461fec commit c8c4e0e
Show file tree
Hide file tree
Showing 2 changed files with 12 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
Expand Up @@ -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)
}
Expand Down

0 comments on commit c8c4e0e

Please sign in to comment.