jeudi 4 juin 2015

Is it possible to list instances with no VPC using Boto get_only_instances()?

There is an AWS account with instances in a VPC and in the EC2 Classic. I try to list them separately using get_only_instances() method, but it seems that filters doesn't work with not set argument (VPC:None).

import boto
import boto.ec2
conn = boto.ec2_connect_to_region('us-east-1', profile_name='qa')
a = conn.get_only_instances(filters={'vpc_id':'vpc-a0876691'})
# len(a) > 0, and should be so
b = conn.get_only_instances(filters={'vpc_id':None})
# len(b) = 0, but should be > 0

BTW. I see following approach to work fine:

b = [i for i in conn.get_only_instances() if not i.vpc_id]
# len(b) > 0, and should be so




Aucun commentaire:

Enregistrer un commentaire