Skip to content

Commit

Permalink
azurerm_virtual_machine_scale_set - changes made to `network… (#3821)
Browse files Browse the repository at this point in the history
The acceptance tests added here are describing the issue as reported by
this ticket #3812

Initially tried to remove the custom Set method which calculates the hashcode similar to what is suggested by hashicorp/terraform#10520 and hashicorp/terraform#15420 but then we got into a position that the test framework was generating a perpetual diff.

So the current solution was to include the other fields in the hashcode calculation.

Many thanks to @kwilczynski

Fixes: #3812
Co-authored-by: Krzysztof Wilczynski [email protected]
  • Loading branch information
alexsapran authored and katbyte committed Jul 30, 2019
1 parent 53078d8 commit ca2d246
Show file tree
Hide file tree
Showing 2 changed files with 414 additions and 19 deletions.
55 changes: 55 additions & 0 deletions azurerm/resource_arm_virtual_machine_scale_set.go
Original file line number Diff line number Diff line change
Expand Up @@ -1554,6 +1554,61 @@ func resourceArmVirtualMachineScaleSetNetworkConfigurationHash(v interface{}) in
if m, ok := v.(map[string]interface{}); ok {
buf.WriteString(fmt.Sprintf("%s-", m["name"].(string)))
buf.WriteString(fmt.Sprintf("%t-", m["primary"].(bool)))

if v, ok := m["accelerated_networking"]; ok {
buf.WriteString(fmt.Sprintf("%t-", v.(bool)))
}
if v, ok := m["ip_forwarding"]; ok {
buf.WriteString(fmt.Sprintf("%t-", v.(bool)))
}
if v, ok := m["network_security_group_id"]; ok {
buf.WriteString(fmt.Sprintf("%s-", v.(string)))
}
if v, ok := m["dns_settings"].(map[string]interface{}); ok {
if k, ok := v["dns_servers"]; ok {
buf.WriteString(fmt.Sprintf("%s-", k))
}
}
if ipConfig, ok := m["ip_configuration"].([]interface{}); ok {
for _, it := range ipConfig {
config := it.(map[string]interface{})
if name, ok := config["name"]; ok {
buf.WriteString(fmt.Sprintf("%s-", name.(string)))
}
if subnetid, ok := config["subnet_id"]; ok {
buf.WriteString(fmt.Sprintf("%s-", subnetid.(string)))
}
if appPoolId, ok := config["application_gateway_backend_address_pool_ids"]; ok {
buf.WriteString(fmt.Sprintf("%s-", appPoolId.(*schema.Set).List()))
}
if appSecGroup, ok := config["application_security_group_ids"]; ok {
buf.WriteString(fmt.Sprintf("%s-", appSecGroup.(*schema.Set).List()))
}
if lbPoolIds, ok := config["load_balancer_backend_address_pool_ids"]; ok {
buf.WriteString(fmt.Sprintf("%s-", lbPoolIds.(*schema.Set).List()))
}
if lbInNatRules, ok := config["load_balancer_inbound_nat_rules_ids"]; ok {
buf.WriteString(fmt.Sprintf("%s-", lbInNatRules.(*schema.Set).List()))
}
if primary, ok := config["primary"]; ok {
buf.WriteString(fmt.Sprintf("%t-", primary.(bool)))
}
if publicIPConfig, ok := config["public_ip_address_configuration"].([]interface{}); ok {
for _, publicIPIt := range publicIPConfig {
publicip := publicIPIt.(map[string]interface{})
if publicIPConfigName, ok := publicip["name"]; ok {
buf.WriteString(fmt.Sprintf("%s-", publicIPConfigName.(string)))
}
if idle_timeout, ok := publicip["idle_timeout"]; ok {
buf.WriteString(fmt.Sprintf("%d-", idle_timeout.(int)))
}
if dnsLabel, ok := publicip["domain_name_label"]; ok {
buf.WriteString(fmt.Sprintf("%s-", dnsLabel.(string)))
}
}
}
}
}
}

return hashcode.String(buf.String())
Expand Down
Loading

0 comments on commit ca2d246

Please sign in to comment.