AWS S3 CLI: Difference between revisions

From SWKLS WIKI
Jump to navigation Jump to search
(Created page with "==AWS CLI S3 Commands== Using the AWS CLI to query S3 for bucket or folder statistics. ===List buckets in account with s3api=== <syntaxhighlight lang="bash"> aws s3api list-...")
 
Line 13: Line 13:
===List objects in bucket with totals===
===List objects in bucket with totals===
<syntaxhighlight lang="bash">
<syntaxhighlight lang="bash">
aws s3 ls --summarize --human-readable --recursive s3://svcostaffbackup/
aws s3 ls --summarize --human-readable --recursive s3://<bucket_name>/
</syntaxhighlight>
</syntaxhighlight>
===List summary of specific folder within a bucket===
===List summary of specific folder within a bucket===
<syntaxhighlight lang="bash">
<syntaxhighlight lang="bash">

Revision as of 18:58, 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://svcostaffbackup/veeam_adsvsc | 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 svcostaffbackup

Summarize Folder Total

aws s3 ls --summarize --human-readable --recursive s3://<bucket_name>/<folder_name> | Select-String -Pattern Total