[英]How to filter not equal to in AWS CLI
我正在嘗試查找所有非窗口圖像:
aws ec2 describe-images --region us-east-2 --image-ids ami-** --filters "Name=platform, Values=windows"
以上為我提供了所有Windows平台ID。 有沒有辦法不在此cli內? 我嘗試過Values!=,<>。 搜索stackoverflow,但未找到任何內容。
此Python3代碼將列出您自己的非 Windows帳戶的所有AMI:
import boto3
ec2_client = boto3.client('ec2', region_name='us-east-2')
images = ec2_client.describe_images(Owners=['self'])
for image in images['Images']:
if 'Platform' not in image:
print(image['ImageId'])
您可以像這樣在cli命令上使用查詢
aws ec2 describe-images --image-ids ami-** --region us-east-2 --query 'Images[?Platform != `windows`]'
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.