Coding Hell

Programming and stuff.

Deploy Octopress to Amazon S3

As I mentioned in my first blog post, I currently use Amazon S3 to host this blog. In this blog post, I’d like to explain my setup and the deployment process.

Setup

First you have to sign up for an Amazon AWS account. Then you create a bucket using the S3 Management Console. The name of the bucket should be the domain you’d like to use later (in this example it’s www.codinghell.ch).

By default, stuff stored in Amazon’s S3 cloud is only accessible to you. To change that, select the bucket and click on “Properties”. Next, click on “Add bucket policy” and add this code:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
{
  "Version": "2008-10-17",
  "Statement": [
    {
      "Sid": "PublicReadForGetBucketObjects",
      "Effect": "Allow",
      "Principal": {
        "AWS": "*"
      },
      "Action": "s3:GetObject",
      "Resource": "arn:aws:s3:::www.codinghell.ch/*"
    }
  ]
}

Also in the properties pane, click on “Website” and enable the checkbox. Use index.html as “Index Document”. The domain part of the endpoint URL is what you should point your actual domain to (CNAME).

Deployment

To deploy the blog, we will use s3cmd. It’s available (or at least installable) in most Linux distributions and via Homebrew for OS X users. After you installed s3cmd, you have to configure it:

1
s3cmd --configure      # start the interactive configuration

Now every time you want to update the content stored on S3, you do the following:

1
2
rake generate
s3cmd sync --no-preserve --delete-removed --recursive public/ s3://www.codinghell.ch

Comments