Today I decided I wanted a blog for myself, a place to put notes I can look at later, share in social networks, or write down for closure. I had many other blogs before, all on different platforms, some of them not existing anymore. I wanted to have something I could keep forever and opted to set up a markdown based static blog using Jekyll, git, and AWS S3. This is how I did it.

jekyll logo

I could have taken the easy path and just use Github pages, but “no pain, no glory”. Also, I wanted to have private storage for the files and remove all magic possible in the process. I still wanted to use git for managing my “project”. I used a private repository in GitHub.

I spent some time reading the documentation for Jekyll, an excellent and simple static site generator. I considered Gatsbyjs, but it is a bigger tool than I needed for this. For Jekyll, I had to fix my Ruby environment, but following the instructions on their site and closing/opening my terminal almost after each line made it work.

After that, I followed the “Quickstart” instructions to set up the local project, and everything worked fine. The next step was pushing this to the remote git repo. This is not different than pushing text files, and basic git knowledge is enough.

Now was time to upload it to the Internet. I want to get more familiar with AWS products, and I decided to use S3 to serve the static side. I create the bucket, configured it for Static Web Hosting (I intentionally don’t link a guide here. AWS changes so fast that most of the examples are outdated). I uploaded an index.html, verified it was working fine, then uploaded manually the static site to check it worked. Like a charm!. But that was a too manual process, and I decided to at least use some CLI to do it. That part took more than I wanted.

I installed the AWSCLI, which is just a “next, next, done” installer. Then created a user without permissions in AWS AIM, saved the key and secret, and added 2 more Statements for the new user. The policy looks like (<<<redacted>>>):

{
    "Version": "2012-10-17",
    "Statement": [
        {
            "Sid": "PublicReadGetObject",
            "Effect": "Allow",
            "Principal": "*",
            "Action": "s3:GetObject",
            "Resource": "arn:aws:s3:::<<<my_bucket_name>>/*"
        },
        {
            "Sid": "JekyllObjectPolicy",
            "Effect": "Allow",
            "Principal": {
                "AWS": "arn:aws:iam::<<<new_user_ARN>>"
            },
            "Action": [
                "s3:DeleteObject",
                "s3:GetObject",
                "s3:PutObject"
            ],
            "Resource": "arn:aws:s3:::<<<my_bucket_name>>/*"
        },
        {
            "Sid": "JekyllBucketPolicy",
            "Effect": "Allow",
            "Principal": {
                "AWS": "arn:aws:iam::<<<new_user_ARN>>"
            },
            "Action": "s3:ListBucket",
            "Resource": "arn:aws:s3:::<<<my_bucket_name>>"
        }
    ]
}

After some reading in the AWS CLI documents about S3, I was able to make it work by setting the new user credentials.

aws configure set aws_access_key_id <<<AWS_ACCESS_KEY_ID>>>
aws configure set aws_secret_access_key <<<AWS_SECRET_ACCESS_KEY>>>

and the using this command to sync the files

aws s3 sync _site/ "s3://<<<my_bucket_name>>" --size-only --exclude "*" --include "*.*" --delete

After that, all needed to do was tunning the theme and the site configuration and write this post!

The last part was getting it under the right domain, for that, I just added a CNAME entry in my domain configuration to point the subdomain notes to the long AWS URL.

If you are reading this, it is because all of the above worked ;) .