代码之家  ›  专栏  ›  技术社区  ›  eekfonky

AWS的jq过滤器用于描述,而不调用jq两次?

  •  0
  • eekfonky  · 技术社区  · 8 年前

    我用这个来过滤快照 Jenkins 在描述中。有没有更有效的方法来做同样的事情?

    aws --region eu-west-1 ec2 describe-snapshots | jq '.Snapshots[] |\ select(.Description | contains("Jenkins"))' | jq -r '.SnapshotId'

    1 回复  |  直到 8 年前
        1
  •  1
  •   joeymiller    8 年前

    也许类似这样,您可以在cli语句中使用JMESPath查询。

     aws --region eu-west-1 ec2 describe-snapshots --query 'Snapshots[?contains(Description, `Jenkins`) == `false`]'