Migrating your Website to AWS from Other Hosts

Internet Status Quo

Many people have websites these days for all kinds of reasons. These reasons run from people trying to give their business an online presence to tacky websites that are bloated with ads trying to sell stuff. In the recent past the go to move to host your website was some of these smaller companies like Blue Host or HostGator. In this post I'll show you some strategies to migrate off these hosts into AWS. Before I tackle this broad topic you need to be aware there are many ways to do this and there are pros and cons to everything. You should experiment with what's best for your needs.

Why make the change?

AWS is just a better answer and if you know what you are doing it can be a lot cheaper. For instance, some people are just hosting a static website with some stock photos and general statements about how much they care about their customers. They could could run that whole website out of S3 for next to nothing. People are also hosting blog software that could be run out of AWS. The simple answer as to why change is it's just a higher quality product that isn't trying to up sell you on SEO services that won't work and email that will get clogged with spam in a matter of days.

Route 53

Route 53 is the starting point to buy or transfer a domain. The menu for anything you want has a clear layout.

Once you have a domain you can create a hosted zone and a record set. This is where Amazon gives you a clear separation to point your domain to the resource that will fuel your website. The simplest resource is an S3 bucket. Before you can use an S3 bucket as the alias target in the record set you must be sure that

  • The bucket has the same name as the record set
  • The index document has public permissions
  • Static website hosting is enabled on the bucket

You can see the immediate benefits of running your static site off of S3. It cost almost nothing, there is no server to maintain and there is a clear decoupling of resources concerns.

Using Route 53 with Lightsail

Lightsail is an AWS service that provisions a lot of the overheard for running standard services. To learn more about Lightsail check out one my previous posts here. The key point is this becomes another way to simply fork lift your website to AWS. All you have to do is provision your Lightsail service and then point your domain name to it. Below is a picture of the record I'm using to point the domain to the server underlying my Lightsail instance. In the context of running a site from an S3 bucket we used Alias in the record set to find the bucket. Since Lightsail simply points to a server we won't use the Alias this time and we'll just input the public ip address.

Now your domain name will take your users right to the Lightsail instance. If you are running a Wordpress site then you have just moved it all over to AWS with little work. You can even use the All-in-one WP migration Wordpress plugin to completely move your site into AWS without having to worry about the database or media files.

Security

Security will of course be a concern as you migrate into AWS. Your site might contain picture or video content that you would like to keep within your site. There are many ways to accomplish this. Most notably is using a CloudFront Distribution with S3 endpoint. Baked in security is just another reason to move your site into AWS. Once your media content is hosted in S3 it's easy to finely control who has access to it. After moving your media in an S3 bucket you can use a bucket policy to be sure that those files are only read with in your site. The below bucket policy will allow you to see media as long the request generates from exampledomain.com.

{
    "Version": "2012-10-17",
    "Id": "http referer policy example",
    "Statement": [
        {
            "Sid": "Allow get requests referred by exampledomain.com.",
            "Effect": "Allow",
            "Principal": "*",
            "Action": "s3:GetObject",
            "Resource": "arn:aws:s3:::<yourMediaBucket>/*",
            "Condition": {
                "StringLike": {
                    "aws:Referer": "http://exampledomain.com/*"
                }
            }
        },
        {
            "Sid": "Explicit deny to ensure requests are allowed only from specific referer.",
            "Effect": "Deny",
            "Principal": "*",
            "Action": "s3:*",
            "Resource": "arn:aws:s3:::<yourMediaBucket>/*",
            "Condition": {
                "StringNotLike": {
                    "aws:Referer": "http://exampledomain.com/*"
                }
            }
        }
    ]
}

Make a Move

Should you migrate from your current hosting provider? You should at least explore it because it will help you learn more about cloud computing and likely find a cheaper and more secure option.