【问题标题】:AWS resource tags OR with botoAWS 资源标签或使用 boto
【发布时间】:2014-12-04 08:47:52
【问题描述】:

查看 aws docs 它说您可以使用过滤器来获取或值,例如:

tag:key=value
The key/value combination of a tag assigned to the resource.

Example: To list the resources with the tag Purpose=X, use:

--filter tag:Purpose=X

Example: To list resources with the tag Purpose=X or the tag Purpose=Y, use:

--filter tag:Purpose=X --filter tag:Purpose=Y

但在 boto 中,您将标签存储在字典中(从获取所有快照):

"filters (dict) – 可选过滤器,可用于限制返回的结果。过滤器以字典的形式提供,由过滤器名称作为键和过滤器值作为值。允许的过滤器名称集/values 取决于正在执行的请求。有关详细信息,请查看 EC2 API 指南。"

如果您想执行 OR,那么您的字典中需要两个条目,键为“tag:Purpose”,这显然是行不通的。有谁知道这是否有解决方法?还是boto不支持OR值过滤?

【问题讨论】:

    标签: amazon-web-services boto


    【解决方案1】:

    没关系,我想通了。

    你可以传递一个列表,所以 {'tag:Purpose': ['X', 'Y']}

    超级简单。

    【讨论】:

      猜你喜欢
      • 2013-10-31
      • 1970-01-01
      • 1970-01-01
      • 2019-03-06
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-11-17
      • 2012-05-21
      相关资源
      最近更新 更多