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] <command> <subcommand> [<subcommand> ...] [parameters]
To see help text, you can run:

  aws help
  aws <command> help
  aws <command> <subcommand> 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.

Categories: Code

Yu

Ideals are like the stars: we never reach them, but like the mariners of the sea, we chart our course by them.

2 Comments

xqiushi · September 1, 2017 at 11:29

Google Chrome 60.0.3112.113 Google Chrome 60.0.3112.113 Mac OS X  10.13.0 Mac OS X 10.13.0

国内好像访问不了

    yu · September 1, 2017 at 14:29

    Google Chrome 60.0.3112.113 Google Chrome 60.0.3112.113 Mac OS X  10.12.6 Mac OS X 10.12.6

    @xqiushi 我北京时候学校教育网用起来还挺好的, 联通似乎不太好…
    蛋痛

Leave a Reply to xqiushi Cancel reply

Your email address will not be published. Required fields are marked *