Skip to content
This repository was archived by the owner on Nov 27, 2023. It is now read-only.

Commit b294595

Browse files
committed
set subnets to publicSubNets for Loadbalancer creation
1 parent a69aa3d commit b294595

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

ecs/awsResources.go

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -450,10 +450,21 @@ func (b *ecsAPIService) ensureLoadBalancer(r *awsResources, project *types.Proje
450450
})
451451
}
452452

453+
var publicSubNetIDs []string
454+
for _, subNetID := range r.subnetsIDs() {
455+
isPublic, err := b.aws.IsPublicSubnet(b.ctx, subNetID)
456+
if err != nil {
457+
return err
458+
}
459+
if isPublic {
460+
publicSubNetIDs = append(publicSubNetIDs, subNetID)
461+
}
462+
}
463+
453464
template.Resources["LoadBalancer"] = &elasticloadbalancingv2.LoadBalancer{
454465
Scheme: elbv2.LoadBalancerSchemeEnumInternetFacing,
455466
SecurityGroups: securityGroups,
456-
Subnets: r.subnetsIDs(),
467+
Subnets: publicSubNetIDs,
457468
Tags: projectTags(project),
458469
Type: balancerType,
459470
LoadBalancerAttributes: loadBalancerAttributes,

0 commit comments

Comments
 (0)