Merge pull request #2880 from bblommers/bugfix/2877

EC2 - Ensure NCI always has a Subnet
This commit is contained in:
Mike Grima 2020-04-16 15:02:45 -07:00 committed by GitHub
commit bdeeeb701a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 33 additions and 9 deletions

View file

@ -776,7 +776,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 []