What is the correct ways to write Boto3 filters to use customise tag name?

后端 未结 4 607
温柔的废话
温柔的废话 2020-12-17 15:51

I am trying to list the instances on tag values of different tag keys For eg> one tag key - Environment, other tag key - Role. My code is given below :

imp         


        
4条回答
  •  误落风尘
    2020-12-17 16:49

    Fix the Env and Role, as I am not sure mine or mootmoot's answer will work because the Array for Values expects strings.

    reservervations = ec2.describe_instances(
            Filters=[
               {'Name': 'tag:environment', 'Values': ['%s'], 'Name': 'tag:role', 'Values': ['%s']} % (Env, Role),
            ]]
        ).get(
            'Reservations', []
        )  
    

提交回复
热议问题