AWS cli cookbook


Get a list of all the buckets under user account
Recursively list contents of a given bucket yurisk.info
Recursively list contents of a given bucket printing sizes in a friendly format
List contents of a bucket, add summary for number of objects and their total size
Get access-list associated with the bucket provided you have permissions to do so on this bucket
Create bucket in default region specified in configuration file
Create the bucket in a given region
Delete an empty bucket, if it is not empty fails with the error BucketNotEmpty
Force deleting non empty bucket provided that objects in it have not been versioned
Simulate removing without deleting anything
Delete recursively contents of a bucket, bucket itself is not deleted
Delete recursively all files in a bucket except JPEG and PNG
Delete only files with a given extension (here JPG)
Delete an empty bucket
Set the existing S3 bucket yurisk.info for hosting the website with the default served document being index.html and the error page for any 4xx response error codes being error.html
Make sure HTML pages of the bucket are accessible by anyone for reading
Verify the website configuration
Delete website configuration from a bucket (doesn't delete any objects iside the bucket)
Upload local file index.html to the bucket yurisk.info at the location /tag/nmap/ and set website redirection to the http://yurisk.info, also set ACL to public-read

Get a list of all the buckets under user account

 aws s3 ls

Recursively list contents of a given bucket

The bucket here is yurisk.info.

 aws s3 ls yurisk.info --recursive

Recursively list contents of a given bucket printing sizes in a friendly format

 aws s3 ls yurisk.com --recursive --human

List contents of a bucket, add summary for number of objects and their total size

aws s3 ls yurisk.info --summarize --human --recursive

Get access-list associated with the bucket provided you have permissions to do so on this bucket

aws s3api get-bucket-acl --bucket yurisk.info

Create bucket in default region specified in configuration file

aws s3 mb s3://testbucket

Create the bucket in a given region

aws s3 mb s3://testbucket --region us-east-1

Delete an empty bucket, if it is not empty fails with the error BucketNotEmpty

aws s3 rb yurisk.info

Force deleting non empty bucket provided that objects in it have not been versioned

aws s3 rb s3://yurisk.com --force

Simulate removing without deleting anything

aws s3 rm s3://yurisk.info --dryrun --rec

Delete recursively contents of a bucket, bucket itself is not deleted

aws s3 rm s3://yurisk.info --recursive

Delete recursively all files in a bucket except JPEG and PNG

aws s3 rm s3://yurisk.info --recursive --exclude "*.jpg" --exclude "*.png" 

Delete only files with a given extension (here JPG)

aws s3 rm s3://yurisk.info --recursive --exclude "*" --include "*.jpg"

Delete an empty bucket

aws s3api delete-bucket --bucket yurisk.info

Set the existing S3 bucket yurisk.info for hosting the website with the default served document being index.html and the error page for any 4xx response error codes being error.html

aws s3 website s3://yurisk.info/ --index-document index.html --error-document error.html

Make sure HTML pages of the bucket are accessible by anyone for reading

aws s3api get-bucket-acl --bucket yurisk.info

Verify the website configuration

aws s3api get-bucket-website --bucket yurisk.info

Delete website configuration from a bucket (doesn't delete any objects inside the bucket)

aws s3api delete-bucket-website --bucket yurisk.info

Upload local file index.html to the bucket yurisk.info at the location /tag/nmap/ and set website redirection to the http://yurisk.info, also set ACL to public-read

aws s3api put-object --bucket yurisk.info --key /tag/nmap/index.html --website-redirect-location http://yurisk.info --body C:/Users/yurisk.info/tag/nmap/index.html --acl public-read