AWS CLI How to Query Multiple Arguments from the same element?

Viewed 1653

I'm trying to use AWS CLI to query S3 objects owned by a specific account AND only if the object has a specific size. Is there any way to do an AND query? These are some of the hundreds of alternatives I've already tried but none of them worked:

aws s3api list-objects-v2 --bucket bucket-name --fetch-owner  --output json --query "'Contents[?Size==`0`].[Key,Owner.ID,Size]' || [?Owner.ID=='00000000111111122222222aaabbbcccdddeeefff']"
aws s3api list-objects-v2 --bucket bucket-name --fetch-owner --output json --query "Contents[?Owner.ID=='00000000111111122222222aaabbbcccdddeeefff']||[?Size==`0`].[Key,Size]"

Any help is welcome!

Thanks in advance!

1 Answers

For future references, this is the final command:

aws s3api list-objects-v2 --bucket bucket-name --fetch-owner --output json --query 'Contents[?(Owner.ID==`00000000111111122222222aaabbbcccdddeeefff` && Size==`0`)].[Key,Size,Owner.ID]'

Thanks a lot @Uberhumus

Related