Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

azurerm_network_interface - all ip_configuration are no longer added to a Load Balancer Backend if one of those ip_configurations is associated with a backend #24470

Merged
merged 1 commit into from
Jan 19, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 16 additions & 13 deletions internal/services/network/network_interface.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import (
type networkInterfaceUpdateInformation struct {
applicationGatewayBackendAddressPoolIDs []string
applicationSecurityGroupIDs []string
loadBalancerBackendAddressPoolIDs []string
loadBalancerBackendAddressPoolIDs map[string]string
loadBalancerInboundNatRuleIDs []string
networkSecurityGroupID string
}
Expand All @@ -34,7 +34,7 @@ func parseFieldsFromNetworkInterface(input networkinterfaces.NetworkInterfacePro

applicationSecurityGroupIds := make(map[string]struct{})
applicationGatewayBackendAddressPoolIds := make(map[string]struct{})
loadBalancerBackendAddressPoolIds := make(map[string]struct{})
loadBalancerBackendAddressPoolIds := make(map[string]string)
loadBalancerInboundNatRuleIds := make(map[string]struct{})

if input.IPConfigurations != nil {
Expand Down Expand Up @@ -62,8 +62,8 @@ func parseFieldsFromNetworkInterface(input networkinterfaces.NetworkInterfacePro

if props.LoadBalancerBackendAddressPools != nil {
for _, pool := range *props.LoadBalancerBackendAddressPools {
if pool.Id != nil {
loadBalancerBackendAddressPoolIds[*pool.Id] = struct{}{}
if v.Name != nil && pool.Id != nil {
loadBalancerBackendAddressPoolIds[*pool.Id] = *v.Name
}
}
}
Expand All @@ -81,7 +81,7 @@ func parseFieldsFromNetworkInterface(input networkinterfaces.NetworkInterfacePro
return networkInterfaceUpdateInformation{
applicationGatewayBackendAddressPoolIDs: mapToSlice(applicationGatewayBackendAddressPoolIds),
applicationSecurityGroupIDs: mapToSlice(applicationSecurityGroupIds),
loadBalancerBackendAddressPoolIDs: mapToSlice(loadBalancerBackendAddressPoolIds),
loadBalancerBackendAddressPoolIDs: loadBalancerBackendAddressPoolIds,
loadBalancerInboundNatRuleIDs: mapToSlice(loadBalancerInboundNatRuleIds),
networkSecurityGroupID: networkSecurityGroupId,
}
Expand All @@ -104,13 +104,6 @@ func mapFieldsToNetworkInterface(input *[]networkinterfaces.NetworkInterfaceIPCo
})
}

loadBalancerBackendAddressPools := make([]networkinterfaces.BackendAddressPool, 0)
for _, id := range info.loadBalancerBackendAddressPoolIDs {
loadBalancerBackendAddressPools = append(loadBalancerBackendAddressPools, networkinterfaces.BackendAddressPool{
Id: utils.String(id),
})
}

loadBalancerInboundNatRules := make([]networkinterfaces.InboundNatRule, 0)
for _, id := range info.loadBalancerInboundNatRuleIDs {
loadBalancerInboundNatRules = append(loadBalancerInboundNatRules, networkinterfaces.InboundNatRule{
Expand All @@ -123,9 +116,19 @@ func mapFieldsToNetworkInterface(input *[]networkinterfaces.NetworkInterfaceIPCo
continue
}

loadBalancerBackendAddressPools := make([]networkinterfaces.BackendAddressPool, 0)
for id, name := range info.loadBalancerBackendAddressPoolIDs {
if config.Name != nil && *config.Name == name {
loadBalancerBackendAddressPools = append(loadBalancerBackendAddressPools, networkinterfaces.BackendAddressPool{
Id: utils.String(id),
})
}

config.Properties.LoadBalancerBackendAddressPools = &loadBalancerBackendAddressPools
}

config.Properties.ApplicationSecurityGroups = &applicationSecurityGroups
config.Properties.ApplicationGatewayBackendAddressPools = &applicationGatewayBackendAddressPools
config.Properties.LoadBalancerBackendAddressPools = &loadBalancerBackendAddressPools
config.Properties.LoadBalancerInboundNatRules = &loadBalancerInboundNatRules
}

Expand Down
Loading