Building this site on AWS!

So, I've been told for years that I should be positng my experiences and projects. 2019 is the year to make that happen!

In typical infrastructure and cloud geek habits, I didn't want to simply hit a Squarespace promo and copy and paste text -- I want to build! .. and do so for less than the cost of a Netflix subscription.

Disclaimer: Squarespace is dope, and is excellent if you're doing e-commerce. It costs about 25.00-30.00 a month, and of course scales up. In this case, I wanted to try and make this happen for way less, and play with the gears myself.

The Architecture

For cost, scale, and features reasons, this site, in its entirety, including repository's and test environement, is all hosted in AWS.

Heres how it happens:

First and foremost, IAM or Identity and Access Management. This maintains my logins, keys, access credentials, two-factor policies, etc. This is the cornerstone of interacting with secure services and practices in AWS.

I run a small t3.micro EC2 instance with an Elastic IP and IPv6 configured. This is my main test machine and my jumping off point for all things. This is hardened security wise, key login based, security group filtered, etc. #donthackme. This box is serves as a small place to draft and edit static content within a repository. This could very well be done locally on my laptop, but I really like having all of my systems in the cloud, and treating my laptops as 'disposeable thin clients'. I rarely keep data 'on-machine' as I travel quite a bit for work and want to be able to lose my laptop on an airplane with no data consequence. Thankfully that scenario has never happened.

All of the content generated on that little EC2 instance is stored in an AWS CodeCommit repository. This includes all of the static images, scripts, CSS, etc. Its all in the repo. A push to this repo places all of the content into the cloud. A successful push triggers an AWS CloudWatch event, which subsequently triggers an AWS Code Pipeline task.

AWS Code Pipeline is very much like Jenkins. This is a CI tool for code integration. Code commits can do really cool things like trigger tests, build environments, or in this case, a copy of all content in the repo into AWS Simple Storage Service, commonly called AWS S3.

AWS S3 is an object store. This is different than a block store, or traditional POSIX file system. These objects are stored in containers called Buckets. AWS S3 has the amazing ability to host static web content from S3 directly. This means we can host web content without running and managing a web server. In addition, S3 is extrremely cheap at 0.03/GB of data stored. There are charges for PUT and GET requests to the Bucket, but at my scale its totally negligible. Furthermore, S3 has nine nine's of durability. Specificially, S3 has 99.999999999% durability and 99.99% availability.

AWS S3 also has a backup and archival service refered to as S3 Glacier. This used to be a separate product as 'AWS Glacier' -- it became part of the S3 product offering late last year. This is the equivalent of tape backups in the cloud. Because its part of S3, its a couple clicks away to automate a backup of an AWS S3 Bucket, into AWS S3 Glacier. So, thats exactly what I do. Thanks to S3 and S3 Glacier, I have automated replication of any changed object from my S3 Bucket, into a Glacier Archive. Glacier costs 0.004/GB, yes thousandths of a cent, and at my scale is a neglible cost, and outstanding, impactful value.

Heres a sample of what a Code Pipeline deployment looks like in the AWS Dashboard:

It's pretty magical to see a deployment hit production with just a 'git push'

But what about delivering the content to the actual reader? Speedy load times, and of course, the best in SSL/TLS? Enter AWS CloudFront. AWS CloudFront is their Content Delivery Network offering. CloudFront is the CDN service that securely delivers content to customers globally with low latency, at high speeds. Simply put, thanks to CloudFront, this site is being served from hundreds of points of presence across the country, giving all my readers super speedy page experiences, for literally a couple dollars on my bill per month. CloudFront is what makes this site fast. My test server (the little EC2 machine) has a load time of about 500ms, or more!. CloudFront drives this time down 80%.

Theres one big, understated piece of AWS thats the glue behind this magic - AWS Route53. Route53 is AWS' DNS offering. This is an API addressable service that also integrates with AWS services seamlessly. Route53 is what allows my mcornstu.net hostname ot have a DNS alias to a CloudFront distribution. This is also the only service on AWS to have a contractual 100% SLA from Amazon Web Services.

Ok, so whats my pipeline look like? This:

And what does this cost?

...About USD 8.37 a month.

Up Next?

Next I'll be adding integrations with messaging services like Slack, or Amazon SNS to notify me of events in Slack Channel, or SMS / Email when commit and build events happen


 

© 2019