Setting up Jekyll on AWS S3 - Part 1

1 minute read

What is Jekyll?

Jekyll is a simple, blog aware, static site generator. It takes a template directory [...] and spits out a complete, static website suitable for serving with Apache or your favorite web server. This is also the engine behind GitHub Pages, which you can use to host your project’s page or blog right here from GitHub.

Using the console

1. Create a bucket

Setting up S3 bucket on AWS is pretty straightforward using the AWS console.

Services » S3 » Create Bucket

Note: If you are using Route53 as your domain registrar. Your bucket name MUST be the FQDN of your intended website URL, otherwise AWS Route53 will not be able to pickup the bucket. I would recommend using it as it will be much easier to integrate your blog with CDN services like Cloudfront and managing SSL certifications will only be a few clicks away.

1.Create S3 bucket on AWS console
Here my bucket name is `www.theredteamguy.com` as I plan to use the `www` as my subdomain for my blog. On this current Jekyll blog the subdomain is `blog`. So my bucket name would be `blog.theredteamguy.com`.

2. Enabling static web hosting & Setting bucket policy

Properties » Statis website hosting

2.Enabling static web hosting
To enable S3 web hosting, simply check `Use this bucket to host a website` box.

Note: Be sure to change the error document to 404.html as Jekyll by uses that as their default error page.

Permissions » Block all public access

3.Enabling public access to S3 bucket
Uncheck `Block all public access` to allow anyone to access the website.

3. Apply public bucket policy

Apply the following bucket policy to enable any resources to read the S3 objects.

{
    "Version": "2012-10-17",
    "Statement": [
        {
            "Sid": "AddPerm",
            "Effect": "Allow",
            "Principal": {
                "AWS": "*"
            },
            "Action": "s3:GetObject",
            "Resource": "arn:aws:s3:::www.theredteamguy.com/*"
        }
    ]
}
To enable S3 web hosting, simply check `Use this bucket to host a website` box.

Note: Be sure to change the resource parameter to your bucket name. /* is required to access all S3 objects.