Skip to content

Commit 72fabb7

Browse files
committed
Pass right SGs for IsExternallyManaged on creation
When IsExternallyManaged we want to make sure additionalSecurityGroups are passed on creation to satisfy user intent. This also prevents the default VPC SG from silently attached to the ec2 and so deviating even more from user intent.
1 parent 3ebf018 commit 72fabb7

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

pkg/cloud/services/ec2/instances.go

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -401,7 +401,14 @@ func (s *Service) getFilteredSubnets(criteria ...*ec2.Filter) ([]*ec2.Subnet, er
401401
// They are considered "core" to its proper functioning.
402402
func (s *Service) GetCoreSecurityGroups(scope *scope.MachineScope) ([]string, error) {
403403
if scope.IsExternallyManaged() {
404-
return nil, nil
404+
ids := make([]string, 0)
405+
for _, sg := range scope.AWSMachine.Spec.AdditionalSecurityGroups {
406+
if sg.ID == nil {
407+
continue
408+
}
409+
ids = append(ids, *sg.ID)
410+
}
411+
return ids, nil
405412
}
406413

407414
// These are common across both controlplane and node machines

0 commit comments

Comments
 (0)