“或" boto3过滤器中的状态 [英] "or" condition in boto3 filters

查看:62
本文介绍了“或" boto3过滤器中的状态的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以在boto3的2个过滤器之间指定或"条件? 例如,我正在使用以下EC2服务呼叫:

Is there a way to specify an "or" condition between 2 filters in boto3? For example I'm using the following EC2 service call:

ec2.snapshots.filter(
        Filters=[
            {
                'Name': 'tag-key',
                'Values': ['SomethingMeaningfull']
            },
            {
                'Name': 'tag:Name',
                'Values': ['OtherMeaningfullThibg']
            },
        ],
        DryRun=False)

在这种情况下,将过滤器评估为"AND"条件,但我希望将其评估为"OR".您可以使用boto3实现此功能吗?

In this case the filter is evaluated as an "AND" condition, but I would like to have it evaluated as an "OR". Is this something that you can achieve with boto3?

推荐答案

过滤器始终以AND组合方式应用.

Filters are always applied in an AND combination.

如果您需要OR组合,则需要多次执行ec2:DescribeSnapshots,每次都使用OR的不同部分.

If you need an OR combination, you'll need to execute ec2:DescribeSnapshots multiple times, each with your different parts of the OR.

这篇关于“或" boto3过滤器中的状态的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆