How to get N files from S3 bucket ordered by max size and modified after certain date using CloudShell?

0

I tried to use this command:

aws s3api list-objects-v2 --bucket BUCKETNAME --query 'Contents[?LastModified>=2022-12-28].Key && sort_by(Contents, &Size)[-5:]'

And while it searches for 5 files ordered by max size, the files may be last modified before 2022-12-28, it seems that part of the query is just being ignored.

What am I doing wrong? With the command above I expected to see files ordered by max size that were modified AFTER 2022-12-28.

Thank you in advance.

1개 답변
0
수락된 답변

If you need 5 object keys sorted in ascending order of size among objects modified after 2022-12-28, how about this?

aws s3api list-objects-v2 --bucket BUCKETNAME --query 'sort_by(Contents[?LastModified>='"2022-12-28"'], &Size)[-5:].Key'

Kihyeon
답변함 일 년 전

로그인하지 않았습니다. 로그인해야 답변을 게시할 수 있습니다.

좋은 답변은 질문에 명확하게 답하고 건설적인 피드백을 제공하며 질문자의 전문적인 성장을 장려합니다.

질문 답변하기에 대한 가이드라인

관련 콘텐츠