Python boto:过滤标签和值

时间:2016-09-10 23:03:40

标签: python amazon-web-services boto boto3

按标记键过滤效果很好:

ec2.get_all_instances(filters={'tag-key': 'MachineType'})

如何按键和值过滤?

"MachineType=DB"

1 个答案:

答案 0 :(得分:1)

<强>宝途

ec2.get_all_instances(filters={"tag:MachineType" : "DB"})

<强> Boto3

import boto3

ec2 = boto3.resource('ec2')
inst_filter = [{'Name':'tag: MachineType', 'Values':['DB']}]
insts = list(ec2.instances.filter(Filters=inst_filter))
for inst in insts:
  print inst.id
相关问题