diff --git a/pkg/cloudprovider/providers/aws/aws.go b/pkg/cloudprovider/providers/aws/aws.go index d6129b6ca0d..2cc06409dab 100644 --- a/pkg/cloudprovider/providers/aws/aws.go +++ b/pkg/cloudprovider/providers/aws/aws.go @@ -741,15 +741,6 @@ func (p *awsSDKProvider) KeyManagement(regionName string) (KMS, error) { return kmsClient, nil } -// stringPointerArray creates a slice of string pointers from a slice of strings -// Deprecated: consider using aws.StringSlice - but note the slightly different behaviour with a nil input -func stringPointerArray(orig []string) []*string { - if orig == nil { - return nil - } - return aws.StringSlice(orig) -} - func newEc2Filter(name string, values ...string) *ec2.Filter { filter := &ec2.Filter{ Name: aws.String(name), diff --git a/pkg/cloudprovider/providers/aws/aws_loadbalancer.go b/pkg/cloudprovider/providers/aws/aws_loadbalancer.go index c148be378c5..25583ca5697 100644 --- a/pkg/cloudprovider/providers/aws/aws_loadbalancer.go +++ b/pkg/cloudprovider/providers/aws/aws_loadbalancer.go @@ -912,9 +912,17 @@ func (c *Cloud) ensureLoadBalancer(namespacedName types.NamespacedName, loadBala // We are supposed to specify one subnet per AZ. // TODO: What happens if we have more than one subnet per AZ? - createRequest.Subnets = stringPointerArray(subnetIDs) + if subnetIDs == nil { + createRequest.Subnets = nil + } else { + createRequest.Subnets = aws.StringSlice(subnetIDs) + } - createRequest.SecurityGroups = stringPointerArray(securityGroupIDs) + if securityGroupIDs == nil { + createRequest.SecurityGroups = nil + } else { + createRequest.SecurityGroups = aws.StringSlice(securityGroupIDs) + } // Get additional tags set by the user tags := getLoadBalancerAdditionalTags(annotations) @@ -996,7 +1004,11 @@ func (c *Cloud) ensureLoadBalancer(namespacedName types.NamespacedName, loadBala // This call just replaces the security groups, unlike e.g. subnets (!) request := &elb.ApplySecurityGroupsToLoadBalancerInput{} request.LoadBalancerName = aws.String(loadBalancerName) - request.SecurityGroups = stringPointerArray(securityGroupIDs) + if securityGroupIDs == nil { + request.SecurityGroups = nil + } else { + request.SecurityGroups = aws.StringSlice(securityGroupIDs) + } glog.V(2).Info("Applying updated security groups to load balancer") _, err := c.elb.ApplySecurityGroupsToLoadBalancer(request) if err != nil {