@@ -259,7 +259,7 @@ func (t *defaultModelBuildTask) buildLoadBalancerSubnets(ctx context.Context, sc
259
259
if err != nil {
260
260
return nil , err
261
261
}
262
- if existingLB != nil {
262
+ if existingLB != nil && string ( scheme ) == aws . StringValue ( existingLB . LoadBalancer . Scheme ) {
263
263
availabilityZones := existingLB .LoadBalancer .AvailabilityZones
264
264
subnetIDs := make ([]string , 0 , len (availabilityZones ))
265
265
for _ , availabilityZone := range availabilityZones {
@@ -271,13 +271,14 @@ func (t *defaultModelBuildTask) buildLoadBalancerSubnets(ctx context.Context, sc
271
271
networking .WithSubnetsResolveLBScheme (scheme ),
272
272
)
273
273
}
274
-
275
274
// for internet-facing Load Balancers, the subnets mush have at least 8 available IP addresses;
276
- // for internal Load Balancers, this is only required if private ip address is not assigned
275
+ // for internal Load Balancers, this is only required if private ip address is not assigned;
276
+ // if the scheme would change, we will call subnet auto discovery
277
277
var privateIpv4Addresses []string
278
278
ipv4Configured := t .annotationParser .ParseStringSliceAnnotation (annotations .SvcLBSuffixPrivateIpv4Addresses , & privateIpv4Addresses , t .service .Annotations )
279
279
if (scheme == elbv2model .LoadBalancerSchemeInternetFacing ) ||
280
- ((scheme == elbv2model .LoadBalancerSchemeInternal ) && ! ipv4Configured ) {
280
+ ((scheme == elbv2model .LoadBalancerSchemeInternal ) && ! ipv4Configured ) ||
281
+ (existingLB != nil && string (scheme ) != aws .StringValue (existingLB .LoadBalancer .Scheme )) {
281
282
return t .subnetsResolver .ResolveViaDiscovery (ctx ,
282
283
networking .WithSubnetsResolveLBType (elbv2model .LoadBalancerTypeNetwork ),
283
284
networking .WithSubnetsResolveLBScheme (scheme ),
0 commit comments