AWS S3 CLI
Jump to navigation
Jump to search
AWS CLI S3 Commands
Using the AWS CLI to query S3 for bucket or folder statistics.
List buckets in account with s3api
aws s3api list-buckets --query "Buckets[].Name"
List bucket size with s3api
aws s3api list-objects --bucket svcostaffbackup --output json --query "[sum(Contents[].Size), length(Contents[])]"
List objects in bucket with totals
aws s3 ls --summarize --human-readable --recursive s3://<bucket_name>/
List summary of specific folder within a bucket
aws s3 ls --summarize --human-readable --recursive s3://<bucket_name>/<folder_name> | Select-String -Pattern Total
List bucket size by polling CloudWatch metrics
aws cloudwatch get-metric-statistics --namespace AWS/S3 --dimensions Name=BucketName,Value=<bucket_name> Name=StorageType,Value=StandardStorage --metric-name BucketSizeBytes --start-time 2019-10-30T00:00:00 --end-time 2019-10-31T00:00:00 --period 86400 --statistics Average --unit Bytes
List multipart uploads
aws s3api list-multipart-uploads --bucket <bucket_name>
Summarize Folder Total
aws s3 ls --summarize --human-readable --recursive s3://<bucket_name>/<folder_name> | Select-String -Pattern Total