diff --git a/nixops/backends/ec2.py b/nixops/backends/ec2.py index 9d0204831..8cb88c8a9 100644 --- a/nixops/backends/ec2.py +++ b/nixops/backends/ec2.py @@ -600,8 +600,9 @@ def _assign_elastic_ip(self, elastic_ipv4, check): def security_groups_to_ids(self, subnetId, groups): sg_names = filter(lambda g: not g.startswith('sg-'), groups) if sg_names != [ ] and subnetId != "": - self.connect_vpc() - vpc_id = self._conn_vpc.get_all_subnets([subnetId])[0].vpc_id + self.connect() + subnet_id_filter = {'Name': 'subnet-id', 'Values': [vpc_id]} + vpc_id = [vpc.vpc_id for vpc in self._conn.subnets.filter(Filters=[subnet_id_filter]).limit(1)][0] groups = map(lambda g: nixops.ec2_utils.name_to_security_group(self._conn, g, vpc_id), groups) return groups