We want to find out files uploaded/creation date of oldest object present in AWS S3 bucket. Could you please suggest how we can get it.
CodePudding user response:
You can use the AWS Command-Line Interface (CLI) to list objects sorted by a field:
aws s3api list-objects --bucket MY-BUCKET --query 'sort_by(Contents, &LastModified)[0].[Key,LastModified]' --output text
This gives an output like:
foo.txt 2021-08-17T21:53:46 00:00
See also: How to list recent files in AWS S3 bucket with AWS CLI or Python