Index of Using AWS S3 Bucket

In this post, I am going to list a set of links to solve the problems in using AWS S3 Bucket(Amazon Simple Storage Service)

Generate your access key

Go to your IAM page: https://console.aws.amazon.com/iam/home , generate an access key in your “Security Credentials” tab.

Save your Access key ID and Secret access key

Install awscli

pip install --upgrade awscli

or

wget 'https://s3.amazonaws.com/aws-cli/awscli-bundle.zip'
unzip awscli-bundle.zip
sudo ./awscli-bundle/install -i /usr/local/aws -b /usr/local/bin/aws

Reading this doc to configure your aws client

Basic usage of s3 in awscli

$ aws s3 ?
usage: aws [options] [ ...] [parameters]
To see help text, you can run:

aws help
aws help
aws help
aws: error: argument subcommand: Invalid choice, valid choices are:

ls | website
cp | mv
rm | sync
mb | rb
presign

“Rename” your bucket

It is impossible to “rename” the bucket. You should create a new one, sync it and destroy the origin one

aws s3 mb s3://[new-bucket]
aws s3 sync s3://[origin-bucket] s3://[new-bucket]
aws s3 rb --force s3://[origin-bucket]

Please refer to this Q&A for more answers

Make s3 public

Go to s3 bucket -> properties -> Static website hosting, enable website hosting. Please refer to this page for more detail.

If we wanna to make all files (include future updates) public, you’d better create a policy as follow:

{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "PublicReadGetObject",
"Effect": "Allow",
"Principal": "*",
"Action": [
"s3:GetObject"
],
"Resource": [
"arn:aws:s3:::example-bucket/*"
]
}
]
}

Please refer to this document for further instruction.