How I cut my hosting costs to less than $1 per month

This is a quick little post about how I cut my hosting costs from about $15/month to less than $1/month (currently 58 cents for April 2017).

In a nutshell

This involved converting my existing Wordpress site – which required a PHP/MySQL server to run – into a static website hosted on AWS. I did this with a tool called Hugo. Hugo is a static website generator which works great for small blogs and portfolio websites. It’s perfect for developers or anyone comfortable with the command line.

Basically instead of logging into an “admin panel” to create posts, you define flat .md files like so:

2017-04-06-hosting-static-sites-using-aws-and-hugo.md Hugo Post Template

You can then use hugo server --watch to view changes locally in real-time, and hugo to build your site. Building your site generates the necessary HTML/CSS/JS files and places them into the /public directory. It is the contents of this public folder that you upload to your production server.

Pros

  • Improved workflow
  • More secure website
  • Faster website
  • Pay only for bandwidth
  • Free SSL certificate using the ACM within AWS

Cons

  • Have to re-write posts as .md files
  • Existing forms, comments & plugins may not work
  • Not ideal for more complex sites which require a CMS or server-side processing

For me the drawbacks didn’t seem too bad. I only had a few posts anyways and if you want comments you can always add Disqus. Also there are cloud-based solutions available for contact forms.

AWS services used

Here’s a quick snapshot of the different AWS services I am using.

AWS Services Used

Amazon provides a Quickstart tool which provisions the necessary CloudFront and S3 resources for you and links them together. From there you can use Route 53 to either purchase a new domain or configure the DNS settings for an existing domain.

You can also create an IAM User and use the AWS CLI to connect and deploy code directly from your local machine. There’s a bit of configuration for this (perhaps a topic for another post), but the end result is being able to run

rm -rf ./public && hugo && aws s3 cp public s3://your-s3-bucket-name/ --recursive

This long command can be stored in a bash script so that you can just do

bash deploy.sh

All in all, so far I am liking Hugo for managing a small blog website.

comments powered by Disqus