All notes
S3

Commandline

docs.aws.amazon.com.

aws s3



#----- ls

aws s3 ls # List all your buckets.
aws s3 ls s3://mybucket
aws s3 ls s3://mybucket --recursive
aws s3 ls s3://mybucket --recursive --human-readable --summarize

#----- mv / cp

aws s3 mv test.txt s3://mybucket/test2.txt
aws s3 mv s3://mybucket . --recursive

#----- presign

# Generate a pre-signed URL to share to people
aws s3 presign s3://my_bucket/some_dir/my_file
# --expires-in (integer): Number of seconds until the pre-signed URL expires. Default is 3600 seconds.

#----- mb / rb

# make a bucket
aws s3 mb s3://mybucket
aws s3 mb s3://mybucket --region us-west-1

# Note that the bucket must be empty in order to remove:
aws s3 rb s3://mybucket
aws s3 rb s3://mybucket --force

#----- sync

aws s3 sync . s3://mybucket
# If test3.txt doesn't exist on local, will delete: s3://mybucket/test3.txt.
aws s3 sync . s3://mybucket --delete
aws s3 sync . s3://mybucket --exclude "*.jpg"

#----- website

# Serve a static website
aws s3 website s3://my-bucket/ --index-document index.html --error-document error.html

aws s3api



aws s3api list-buckets
# {
#     "Owner": {
#         "DisplayName": "me",
#         "ID": "id_number_lah"
#     },
#     "Buckets": [
#         {
#             "CreationDate": "2017-01-15T04:41:29.000Z",
#             "Name": "my_bucket"
#         }
#     ]
# }