AWS S3 CLI: Difference between revisions
Jump to navigation
Jump to search
Line 27: | Line 27: | ||
===List multipart uploads=== | ===List multipart uploads=== | ||
<syntaxhighlight lang="bash"> | <syntaxhighlight lang="bash"> | ||
aws s3api list-multipart-uploads --bucket | aws s3api list-multipart-uploads --bucket <bucket_name> | ||
</syntaxhighlight> | </syntaxhighlight> | ||
===Summarize Folder Total=== | ===Summarize Folder Total=== | ||
<syntaxhighlight lang="bash"> | <syntaxhighlight lang="bash"> |
Revision as of 18:59, 26 March 2020
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=svcostaffbackup 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