我正在尝试从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规范使用||
。这里参考
尝试,
aws ec2 describe-volumes --query 'Volumes[?!not_null(Tags[?Key == `MakeSnapshot || MakeDevSnapshot`].Value)] | [].[VolumeId]' --output text