【问题标题】:List volumes missing specific tags列出缺少特定标签的卷
【发布时间】:2020-04-09 19:24:13
【问题描述】:

我正在尝试从 AWS CLI 中列出缺少特定标签键的卷。虽然我可以使用以下命令列出缺少特定键的卷。

aws ec2 describe-volumes  --query 'Volumes[?!not_null(Tags[?Key == `MakeSnapshot`].Value)] | [].[VolumeId]' --output text

在查询语句中寻找逻辑或运算,我可以通过它列出所有缺少两个键中的任何一个的卷,类似于此。

aws ec2 describe-volumes  --query 'Volumes[?!not_null(Tags[?Key == `MakeSnapshot|MakeDevSnapshot`].Value)] | [].[VolumeId]' --output text

是否可以在查询/James Path 搜索中执行此类逻辑 AND/OR 操作?

【问题讨论】:

    标签: amazon-web-services aws-cli boto jmespath


    【解决方案1】:

    OR 表达式的 JMESPath 规范使用 ||。参考here

    试试,

    aws ec2 describe-volumes  --query 'Volumes[?!not_null(Tags[?Key == `MakeSnapshot || MakeDevSnapshot`].Value)] | [].[VolumeId]' --output text
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2015-10-12
      • 2020-10-27
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多