Created
July 28, 2023 07:15
-
-
Save bsingr/1e2f3f3af4473a227fe85df0121a457c to your computer and use it in GitHub Desktop.
aws_s3_last_modified_buckets
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
export AWS_ACCESS_KEY_ID= | |
export AWS_SECRET_ACCESS_KEY= | |
export AWS_DEFAULT_REGION= | |
buckets_wsv=$(aws s3api list-buckets --query "Buckets[].Name" --output text) | |
echo $buckets_wsv | |
echo | |
echo "---" | |
echo | |
buckets=($buckets_wsv) | |
echo "bucket,last_modified_object,last_modified_object_updated_at,last_modified_object_size" | |
for bucket in "${buckets[@]}" | |
do | |
echo -n "$bucket," | |
last_modified=$(aws s3api list-objects-v2 --bucket $bucket | jq -r '.[] | max_by(.LastModified) | [.Key, .LastModified, .Size] | @csv') | |
echo $last_modified | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment