0
在VPC和EC2 Classic中有一個包含實例的AWS賬戶。我嘗試使用get_only_instances()方法分別列出它們,但似乎過濾器不適用於未設置參數(VPC:無)。是否可以使用Boto get_only_instances()來列出沒有VPC的實例?
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。我看到下面的方法來很好地工作:
b = [i for i in conn.get_only_instances() if not i.vpc_id]
# len(b) > 0, and should be so