Example (deploying a static website)

Warning: this documentation assumes Linux or OS X. Equivalent steps should be possible on Windows.

As an example, imagine that have used the wonderful Hugo (a static site generated written in Go, similar to Jekyll) to create a new website and that you are ready to deploy it.

You run hugo and it generated a version of your website ready to be uploaded to an S3 bucket in a subdirectory called ./public and looks a bit like this:-

├── 404.html
├── fonts
│   ├── icon.eot
│   ├── icon.svg
│   ├── icon.ttf
│   └── icon.woff
├── images
│   └── favicon.ico
├── index.html
├── index.xml
├── javascripts
│   ├── application.js
│   └── modernizr.js
├── license
│   ├── index.html
│   └── index.xml
├── sitemap.xml
└── stylesheets
    ├── application.css
    ├── highlight
    │   └── highlight.css
    └── palettes.css

Authorizing s3up with AWS

This documentation assumes that you know how to create an AWS IAM user with access and secret keys and have been able to grant that user access to read and write to your website’s bucket. If you don’t you can follow these instructions to create an IAM user and a bucket.

If it doesn’t already exist create a folder in your computer’s home directory called .aws. You could this by running:-

mkdir ~/.aws

Within ~/.aws, create a text file called credentials.

In it create (or add to the end) the following (replacing your-aws-access-key and your-aws-secret-key with your AWS user’s access and secret keys):-

aws_region = your-buckets-region
aws_access_key_id = your-aws-access-key
aws_secret_access_key = your-aws-secret-key

Note: what you’ve actually done here is create an AWS_PROFILE on your system, and if you want to add multiple profiles you’ll need to give them unique names — in this example profile is named my-first-profile.

Getting a list of files to upload

s3up doesn’t have the ability to search through directories to find files to upload. Instead you’ll need to use another command line tool built into your computer to tell s3up what to upload. To do this, you can use the tool: find. Something like this should work:-

find public

If you run that on its own, you’ll get something like this:-

[…etc etc…]

Combining find with s3up

Now we can bring it all together into a single command (remember to replace your-buckets-name with your S3 bucket’s name and your-buckets-region with the AWS region where your S3 bucket is, for example eu-west-1):-

export AWS_PROFILE=my-first-profile; \
	export AWS_REGION=your-buckets-region; \
	find public | xargs s3up --strip 1 --bucket your-buckets-name


  • --strip 1 will remove one folder level (in this case public/) from all the files when they are uploaded
  • xargs is another command line tool that takes the output from find and passes it into s3up