Set multiple Security Groups when calling modify_network_interface_attribute (#3911)

This commit is contained in:
Josh McCullen 2021-05-07 13:50:26 +01:00 committed by GitHub
commit 12b409e0de
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 12 additions and 10 deletions

View file

@ -479,10 +479,10 @@ class NetworkInterfaceBackend(object):
found_eni.instance.detach_eni(found_eni)
def modify_network_interface_attribute(self, eni_id, group_id):
def modify_network_interface_attribute(self, eni_id, group_ids):
eni = self.get_network_interface(eni_id)
group = self.get_security_group_from_id(group_id)
eni._group_set = [group]
groups = [self.get_security_group_from_id(group_id) for group_id in group_ids]
eni._group_set = groups
def get_all_network_interfaces(self, eni_ids=None, filters=None):
enis = self.enis.values()

View file

@ -56,11 +56,10 @@ class ElasticNetworkInterfaces(BaseResponse):
return template.render()
def modify_network_interface_attribute(self):
# Currently supports modifying one and only one security group
eni_id = self._get_param("NetworkInterfaceId")
group_id = self._get_param("SecurityGroupId.1")
group_ids = self._get_multi_param("SecurityGroupId")
if self.is_not_dryrun("ModifyNetworkInterface"):
self.ec2_backend.modify_network_interface_attribute(eni_id, group_id)
self.ec2_backend.modify_network_interface_attribute(eni_id, group_ids)
return MODIFY_NETWORK_INTERFACE_ATTRIBUTE_RESPONSE
def reset_network_interface_attribute(self):