@@ -912,34 +912,15 @@ func (s *Service) getNetworkInterfaceSecurityGroups(interfaceID string) ([]strin
912
912
}
913
913
914
914
func (s * Service ) attachSecurityGroupsToNetworkInterface (groups []string , interfaceID string ) error {
915
- existingGroups , err := s .getNetworkInterfaceSecurityGroups (interfaceID )
916
- if err != nil {
917
- return errors .Wrapf (err , "failed to look up network interface security groups: %+v" , err )
918
- }
919
-
920
- totalGroups := make ([]string , len (existingGroups ))
921
- copy (totalGroups , existingGroups )
922
-
923
- for _ , group := range groups {
924
- if ! containsGroup (existingGroups , group ) {
925
- totalGroups = append (totalGroups , group )
926
- }
927
- }
928
-
929
- // no new groups to attach
930
- if len (existingGroups ) == len (totalGroups ) {
931
- return nil
932
- }
933
-
934
- s .scope .Info ("Updating security groups" , "groups" , totalGroups )
915
+ s .scope .Info ("Updating security groups" , "groups" , groups )
935
916
936
917
input := & ec2.ModifyNetworkInterfaceAttributeInput {
937
918
NetworkInterfaceId : aws .String (interfaceID ),
938
- Groups : aws .StringSlice (totalGroups ),
919
+ Groups : aws .StringSlice (groups ),
939
920
}
940
921
941
922
if _ , err := s .EC2Client .ModifyNetworkInterfaceAttribute (input ); err != nil {
942
- return errors .Wrapf (err , "failed to modify interface %q to have security groups %v" , interfaceID , totalGroups )
923
+ return errors .Wrapf (err , "failed to modify interface %q to have security groups %v" , interfaceID , groups )
943
924
}
944
925
return nil
945
926
}
@@ -1016,16 +997,6 @@ func filterGroups(list []string, strToFilter string) (newList []string) {
1016
997
return
1017
998
}
1018
999
1019
- // containsGroup returns true if a list contains a string.
1020
- func containsGroup (list []string , strToSearch string ) bool {
1021
- for _ , item := range list {
1022
- if item == strToSearch {
1023
- return true
1024
- }
1025
- }
1026
- return false
1027
- }
1028
-
1029
1000
func getInstanceMarketOptionsRequest (spotMarketOptions * infrav1.SpotMarketOptions ) * ec2.InstanceMarketOptionsRequest {
1030
1001
if spotMarketOptions == nil {
1031
1002
// Instance is not a Spot instance
0 commit comments