Migrate from AWS EC2 to Lightsail
Tags: aws, cloud, ec2, lightsail
Published: 2018-10-04 23:57:31

---
title: Migrate from AWS EC2 to Lightsail
published: true
description: A brief overview of migrating from AWS EC2/RDS/EFS to Lightsail
tags: aws, cloud, ec2, lightsail
cover_image: https://blog.davidjeddy.com/wp-content/uploads/2018/10/EC2_to_Lightsail.png
---

Cross posted from my personal blog [https://blog.davidjeddy.com](https://blog.davidjeddy.com).

<!-- wp:paragraph -->
<p>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, Route 53 domain, and outbound traffic. Looking around Lightsail is a much simpler and cheaper solution; so I started migrating.</p>
<!-- /wp:paragraph -->

<!-- wp:heading -->
<h2>AWS Lightsail in a nutshell</h2>
<!-- /wp:heading -->

<!-- wp:paragraph -->
<p>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. </p>
<!-- /wp:paragraph -->

<!-- wp:heading -->
<h2>The Process</h2>
<!-- /wp:heading -->

<!-- wp:heading {"level":4} -->
<h4>SSH into machine</h4>
<!-- /wp:heading -->

<!-- wp:paragraph -->
<p>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.</p>
<!-- /wp:paragraph -->

<!-- wp:heading {"level":4} -->
<h4>Updated OS</h4>
<!-- /wp:heading -->

<!-- wp:paragraph -->
<p>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.</p>
<!-- /wp:paragraph -->

<!-- wp:heading {"level":4} -->
<h4>Install services</h4>
<!-- /wp:heading -->

<!-- wp:paragraph -->
<p><a href="https://www.digitalocean.com/community/tags/lemp?type=tutorialshttps://www.digitalocean.com/community/tags/lemp?type=tutorialshttps://www.digitalocean.com/community/tags/lemp?type=tutorials">LEMP </a>stack <a href="https://knowyourmeme.com/memes/win-epic-win-for-the-win">FTW</a></p>
<!-- /wp:paragraph -->

<!-- wp:list -->
<ul><li>Nginx config is always all over the place. Configuration JSON files everywhere. Ugg.</li><li>PHP/PHP-FPM was easy as usual. I went with the Unix sock style configuration.</li><li>MySQL, <a href="https://www.techrepublic.com/article/how-to-harden-mysql-security-with-a-single-command/https://www.techrepublic.com/article/how-to-harden-mysql-security-with-a-single-command/">DO NOT FORGET TO RUN THE HARDENING SCRIPT</a></li><li><br/></li></ul>
<!-- /wp:list -->

<!-- wp:heading {"level":4} -->
<h4>Migrate Wordpress</h4>
<!-- /wp:heading -->

<!-- wp:paragraph -->
<p>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 <strong>Settings menu</strong> item. </p>
<!-- /wp:paragraph -->

<!-- wp:image {"id":957} -->
<figure class="wp-block-image"><img src="https://blog.davidjeddy.com/wp-content/uploads/2018/10/wp_export.png" alt="" class="wp-image-957"/><figcaption>WIN!</figcaption></figure>
<!-- /wp:image -->

<!-- wp:paragraph -->
<p>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.</p>
<!-- /wp:paragraph -->

<!-- wp:heading {"level":4} -->
<h4>Update domain</h4>
<!-- /wp:heading -->

<!-- wp:paragraph -->
<p>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 <a href="https://en.wikipedia.org/wiki/Top-level_domain">TLD</a> to redirect to blog.* thus not losing any organic traffic or mess with anyone's bookmarks.</p>
<!-- /wp:paragraph -->

<!-- wp:heading {"level":4} -->
<h4>Backups</h4>
<!-- /wp:heading -->

<!-- wp:paragraph -->
<p>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. <a href="https://docs.aws.amazon.com/lightsail/2016-11-28/api-reference/API_CreateInstanceSnapshot.html">I can even do this via the CLI API</a>. Since the instance now contains my entire applications and database it is an all-inclusive backup. <a href="https://www.cloudcomputing-news.net/news/2016/nov/02/testing-your-disaster-recovery-plans-best-practice-guide/">Be sure to test your recovery plan!</a></p>
<!-- /wp:paragraph -->

<!-- wp:heading {"level":4} -->
<h4>Decommission old infrastructure</h4>
<!-- /wp:heading -->

<!-- wp:paragraph -->
<p>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. </p>
<!-- /wp:paragraph -->

<!-- wp:heading -->
<h2>Conclusion</h2>
<!-- /wp:heading -->

<!-- wp:paragraph -->
<p>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.</p>
<!-- /wp:paragraph -->