Migrating from AWS EC2 to AWS Lightsail.

As is good practice for any and all Cloud Engineers I am constantly looking for ways to minimize cost of operations and simpify operations. For this blog specifically it currently costs around 25 USD / mo. The costs comes from the EC2 instance, RDS ( + 14 day back ups), and a EFS volume, Route52 domain, and outbound traffic. Looking around Lightsail is a much simpler and cheaper solution; so I started migrating.

AWS Lightsail in a nutshell

Lightsail is, ostensibly, a dumbed down UI for simple VPS administration. Servers can be provisioned, a SSH key is provided, port access, and disk snapshots are all available via the UI; a simplified UI. 

The Process

Provision VPS

SSH into machine

This is standard fair Linux access. The Lightsail UI provides a download link for the *.pem file. Download it, move it to ~/.ssh, change permissions to 0400 and connect as normal. The UI also provides a web based SSH interface. I suspect this leverages AWS Systems Manager in the background.

Updated OS

Again, pretty standard fare, however I did an upgrade to Ubuntu 18.04. Call me brave but this is a personal blog site not a corporate payment system.

Install services

LEMP stack FTW

  • Nginx config is always all over the place. Configuration JSON files everywhere. Ugg.
  • PHP/PHP-FPM was easy as usual. I went with the Unix sock style configuration.
  • MySQL, DO NOT FORGET TO RUN THE HARDENING SCRIPT

Migrate WordPress

With the core services install I move on to the unknown part of the migration. How to migrate WordPress. Luckily WordPress contains basic import / export functionality via the Settings menu item. 

WIN!

Took the output and imported it into the new instance. Everything went fine except the Link Directory content. That sucked, I had to find an alterate solution and migrate the content manually. 🙁 Boo.

Update domain

With the content moved I went to Route 53 and setup a subdomain (https://blog.davidjeddy.com) and pointed it at the new static IP provisioned via the Lightsail UI. I then waited for propagation. Once I was sure blog.* pointed correctly I edited the TLD to redirect to blog.* thus not losing any organic traffic or mess with anyone’s bookmarks.

Backups

This is the web, crashes happen. It is a fact of life. For LightSail backup up my application was as easy as clicking ‘Create Snapshot’ in the UI and the disk is imaged. I can even do this via the CLI API. Since the instance now contains my entire applications and database it is an all-inclusive backup. Be sure to test your recovery plan!

Decommission old infrastructure

Once I was sure everything was running I did a ‘soft off’ of the old location. Specifically added a banner to the top of the site indicating the move was happening. At the end of the week I checked traffic patterns to ensure the old instance was no longer receiving traffic. Then, lights off. 

Conclusion

Average cost before migration was running in the range of 25 USD / month. Projected cost after migration is around 10 USD / month. While not thousands per month this shows that AWS is serious about giving Linode / Dreamhost, other basic VPS providers a run for the money. Low cost + AWS infrastructure = market competition from the bottom to the top.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.