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
Create expiring link/hot-link to the object in s3 bucket, pre-sign link
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
Create expiring link/hot-link to the object in s3 bucket, pre-sign link
aws s3 presign s3://yurisk.info/download.me --expires-in 259200 --profile awsadminprofile --region eu-west-1
Here:
download.me
- object in S3 to create download link to. NOTE: You don't have to make this object public in any way, still, anyone with the link will have read access to it.
--expires-in 259200
- Expiration time starting from now in seconds/ Here it is set to 3 days. If this parameter is absent, the default expiration is 3600 seconds or 1 hour.
--region <name>
- region location of the object, if it is different from the default one set in your AWS profile.
--profile
- optional. Only needed if you ahve multiple AWS IAM user profiles configured on the host.
Output:
ttps://yurisk.info.s3.amazonaws.com/download.me?AWSAccessKeyId=AKIA2QEA3PKXP5TYM2GO&Signature=0WU7257sOAy9odrh6Fs88d0Vp94%3D&Expires=1599498917
The expires
here is epoch time when the link expires.
Follow me on https://www.linkedin.com/in/yurislobodyanyuk/ not to miss what I publish on Linkedin, Github, blog, and more.