#2877 - Ensure NetworkInterfaces are assigned to the default Subnet

This commit is contained in:
Bert Blommers 2020-04-08 13:53:53 +01:00
commit 5c7e0b56af
3 changed files with 56 additions and 2 deletions

View file

@ -775,7 +775,14 @@ class Instance(TaggedEC2Resource, BotoInstance):
if "SubnetId" in nic:
subnet = self.ec2_backend.get_subnet(nic["SubnetId"])
else:
subnet = None
# Get default Subnet
subnet = [
subnet
for subnet in self.ec2_backend.get_all_subnets(
filters={"availabilityZone": self._placement.zone}
)
if subnet.default_for_az
][0]
group_id = nic.get("SecurityGroupId")
group_ids = [group_id] if group_id else []