All Posts Tagged “aws s3”

Upload files to Amazon S3 when Travis CI builds pass

Assume that you want to upload a xxx.whl file generated by pip wheel to Amazon S3 so that you will be able to run pip install https://url/to/s3/bucket/xxx.whl.

CAUTION! By default, only master branch's builds could trigger deployments in Travis CI.


  - pip install -U pip
  - pip install wheel

  - python test

  - pip wheel --wheel-dir=wheelhouse .

  provider: s3
  access_key_id: "YOUR_KEY"
  secret_access_key: "YOUR_SECRET"
  bucket: YOUR_BUCKET
  acl: public_read
  local_dir: wheelhouse
  upload_dir: wheels
  skip_cleanup: true
# install from an URL directly
$ pip install https://url/to/s3/bucket/wheels/xxx.whl


Setup a static website on Amazon S3

Say that you would like to host your static site on Amazon S3 with a custom domain and, of course, HTTPS.

Create two S3 buckets

To serve requests from both root domain such as and subdomain such as, you must create two buckets named exactly and

In this post, I assume that you want to redirect to


Upload your static files

$ cd /path/to/your_project_root/

$ aws s3 sync . s3:// \
--acl "public-read" \
--exclude "*.DS_Store" \
--exclude "*.gitignore" \
--exclude ".git/*" \

$ aws s3 website s3:// --index-document index.html --error-document error.html


Setup bucket policy for public accessing

In your S3 Management Console, click bucket > Properties > Edit bucket policy, enter:

    "Version": "2012-10-17",
    "Statement": [
            "Sid": "AddPerm",
            "Effect": "Allow",
            "Principal": "*",
            "Action": "s3:GetObject",
            "Resource": "*"

Setup www redirecting

In your S3 Management Console, click bucket > Properties > Static Website Hosting, choose Redirect all requests to another host name, type

Now you're able to access your website via:

Configure a custom domain

In the "Setting Up a Static Website Using a Custom Domain" guide I mentioned above, it uses Amazon Route 53 to manage DNS records; In this post, I use CloudFlare as my website's DNS provider instead.

  • Create a CNAME for to point to
  • Create a CNAME for to point to

Yep, you CAN create a CNAME record for root domain on CloudFlare, just like your can add an "Alias" on Route 53.

Wait for the DNS records to propagate then visit

awscli: Command-line Interface for Amazon Web Services

awscli is a command-line interface for all Amazon Web Services (AWS).


$ pip install awscli

$ aws configure

# sync files between S3 buckets
$ aws s3 sync s3://your_bucket_1/media s3://your_bucket_2/media \
--acl "public-read" \
--exclude "track_audio/*"

$ aws s3 rm s3://your_bucket_1/media/track_audio --recursive


$ s3cmd setacl s3://your_bucket_1/media --acl-public --recursive