我尝试从 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 运算?
最佳答案
OR 表达式的 JMESPath 规范使用 ||
。引用here
尝试,
aws ec2 describe-volumes --query 'Volumes[?!not_null(Tags[?Key == `MakeSnapshot || MakeDevSnapshot`].Value)] | [].[VolumeId]' --output text
关于amazon-web-services - 列出缺少特定标签的卷,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60734432/