diff --git a/azure/services/networkinterfaces/spec.go b/azure/services/networkinterfaces/spec.go index 4e73cf6101a..5f287fd6034 100644 --- a/azure/services/networkinterfaces/spec.go +++ b/azure/services/networkinterfaces/spec.go @@ -58,9 +58,8 @@ type NICSpec struct { // IPConfig defines the specification for an IP address configuration. type IPConfig struct { - PrivateIP string - PublicIP bool - PublicIPAddress string + PrivateIP *string + PublicIPAddress *string } // ResourceName returns the name of the network interface. @@ -164,21 +163,21 @@ func (s *NICSpec) Parameters(ctx context.Context, existing interface{}) (paramet Name: to.StringPtr(s.Name + "-" + strconv.Itoa(i)), InterfaceIPConfigurationPropertiesFormat: newIPConfigPropertiesFormat, } - if c.PrivateIP == "" { - config.InterfaceIPConfigurationPropertiesFormat.PrivateIPAllocationMethod = network.IPAllocationMethodDynamic - } else { + if c.PrivateIP != nil && *c.PrivateIP != "" { config.InterfaceIPConfigurationPropertiesFormat.PrivateIPAllocationMethod = network.IPAllocationMethodStatic - config.InterfaceIPConfigurationPropertiesFormat.PrivateIPAddress = &c.PrivateIP + config.InterfaceIPConfigurationPropertiesFormat.PrivateIPAddress = c.PrivateIP + } else { + config.InterfaceIPConfigurationPropertiesFormat.PrivateIPAllocationMethod = network.IPAllocationMethodDynamic } - if c.PublicIP && c.PublicIPAddress != "" { + if c.PublicIPAddress != nil && *c.PublicIPAddress != "" { config.InterfaceIPConfigurationPropertiesFormat.PublicIPAddress = &network.PublicIPAddress{ PublicIPAddressPropertiesFormat: &network.PublicIPAddressPropertiesFormat{ PublicIPAllocationMethod: network.IPAllocationMethodStatic, - IPAddress: &c.PublicIPAddress, + IPAddress: c.PublicIPAddress, }, } - } else if c.PublicIP { + } else if c.PublicIPAddress != nil { config.InterfaceIPConfigurationPropertiesFormat.PublicIPAddress = &network.PublicIPAddress{ PublicIPAddressPropertiesFormat: &network.PublicIPAddressPropertiesFormat{ PublicIPAllocationMethod: network.IPAllocationMethodDynamic,