Skip to content

Commit b62d401

Browse files
committed
🐛ec2: instances: fix check for public subnets
It's not enough to check MapPublicIPOnLaunch since public subnets can have that off.
1 parent d62768f commit b62d401

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

pkg/cloud/services/ec2/instances.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -334,7 +334,7 @@ func (s *Service) findSubnet(scope *scope.MachineScope) (string, error) {
334334
*subnet.SubnetId, *subnet.AvailabilityZone, *failureDomain)
335335
continue
336336
}
337-
if scope.AWSMachine.Spec.PublicIP != nil && *scope.AWSMachine.Spec.PublicIP && !*subnet.MapPublicIpOnLaunch {
337+
if scope.AWSMachine.Spec.PublicIP != nil && *scope.AWSMachine.Spec.PublicIP && !s.scope.Subnets().FindByID(*subnet.SubnetId).IsPublic {
338338
errMessage += fmt.Sprintf(" subnet %q is a private subnet.", *subnet.SubnetId)
339339
continue
340340
}

0 commit comments

Comments
 (0)