How To Migrate External Domain DNS Service to AWS Route 53
Migrate/Change External DNS Service to AWS Route 53

How To Migrate External Domain DNS Service to AWS Route 53

Do you have a domain name that you purchased from registrars like Namecheap, GoDaddy, Bluehost, etc. in the past that is probably not in use (inactive) and now you might be looking to host a website using it with the minimum possible cost?

If yes, then read this post because today I'm going to show you how you can use an external domain name and migrate the registrar's DNS to AWS Route 53. This process will eventually help you utilize that domain in AWS to host a simple web app or a static website for just $0.50 - $1.00 per Month.

Disclaimer: Price may vary based on your AWS services usage. A simple static website can be hosted for just $0.50 - $1.00 per month.

What is a domain name?

A domain is an easy-to-remember, user-friendly name which maps to an IP address to access a web server from the client machine. In plain English, it is a text that we type in the browser to reach any website on the internet. For example, 'google.com' is a domain name that we use to reach Google servers.

The actual IP address of a website is a complex numerical address like 35.153.63.85 which is very hard to remember but thanks to DNS or Domain Name System which help users to use domain names and can route traffic to web servers. In AWS, Route 53 is a globally distributed DNS service that translates custom human-readable domain names into IP addresses.

What is DNS?

DNS stands for Domain Name System. It's a group of globally distributed database servers that act as a "Phonebook" for the whole Internet and maps a domain name/subdomain name to the device's IP address. This group of database servers works together by delegating the request to another server to resolve the domain name to the IP address. The actual process of resolving a domain name is complex and involves querying multiple name servers but DNS also maintains a cache of widely used resolved domains at a different layer for faster discovery. I won't go into more details of how exactly it works but here is an infographic that explains the process on a high level.

No alt text provided for this image
Figure: 1 How Route 53 routes traffic for your domain

Intro To AWS Route 53?

AWS Route 53 is a highly available, scalable Domain name web service. It's an AWS-managed service where you can manage all your DNS records to connect your AWS resources to domain names.

It can be used to perform three main functions -

  1. Domain Registration or Transfer
  2. DNS Routing
  3. Health checks on resources

When you register a domain name using Route 53, the service automatically provides the DNS service for your domain. The DNS service is provided by Route 53 by creating a "hosted zone" for your domain. Once it creates a hosted zone, a set of four services are assigned to your domain name and configured as Domain Name Servers.

No alt text provided for this image
Figure 2: Hosted Zone - Set of name servers

This set of four servers is responsible to resolve the domain name, say - example.com to AWS resources like an application load balancer, S3 bucket static website endpoint, cloud front distribution endpoint, or any other AWS resource with the IP address.

Common DNS Records In Route 53

  1. A Record: Route traffic to a web server using an IPv4 address in dotted decimal format. For example - 192.0.2.1
  2. AAAA Record: Route traffic to a web server using an IPv6 address in hexadecimal format. For example - 2001:0db8:85a3:0:0:8a2e:0370:7334
  3. CNAME Record - Route traffic from a sub-domain to a domain name. For example, it would route traffic from www.example.com to the apex or naked domain name example.com.
  4. Alias records: Alias records let you route traffic to selected AWS resources like CloudFront distribution and Amazon S3 bucket. Unlike CNAME, you can create an alias record for the zone apex (example.com) and route traffic to the sub-domain (www.example.com), provided that there is no CNAME record present for the sub-domain(www.example.com).

Points to Remember:

  1. The DNS protocol does not allow you to create a CNAME record for the top node of a DNS namespace, also known as the zone apex. For example, if you register the DNS name example.com, the zone apex is example.com. You cannot create a CNAME record for example.com, but you can create CNAME records for www.example.com, newproduct.example.com, and so on.
  2. If you create a CNAME record for a subdomain, you cannot create any other records for that subdomain. For example, if you create a CNAME for www.example.com, you cannot create any other records for which the name field's value is www.example.com.

Steps to Migrate DNS From Third Party to AWS Route53

Now that you have some basic understanding of domain name and DNS and the benefits of using Route 53 as a DNS service, we can now learn how to migrate DNS service from any third-party DNS provider to Route 53. Please note that migrating DNS is relatively a simple process, but it should be done carefully to avoid any downtime to your application.

Domain registrars and DNS services both are two different things. Most domain registrars provide DNS services as an additional service along with domain registration.

Before we go into migration steps, I just want to clear up how you can get DNS services:

  1. Domain name registrars can offer DNS hosting services as an additional service along with domain registration.
  2. Web Hosting providers
  3. Dedicated DNS Hosting (Route 53).

Scenario 1: Brand New Domain from External Registrar to Route 53

To begin the process, it is necessary to have a registered domain name that is not managed through Route 53. While you can typically register a domain name using Route 53 for a cost ranging from $9.00 to $13.00 for most top-level domains (TLDs), there are occasions when you can find the same domain names at lower prices from third-party registrars such as Namecheap. Currently, Namecheap is running a special promotion where new customers can obtain a ".COM" domain for just $5.98 by using the promo code NEWCOM598.

Therefore, if you are experimenting and require a domain name for hands-on usage in AWS, you can purchase an inexpensive domain from a registrar outside of Route 53. Later on, you can migrate the DNS to Route 53 to utilize it within your AWS Account. Let's get started.

Step 1: Domain Name

In this tutorial, I'm using one of the domains "example.com" that I had registered at Namecheap long back but never used to host any website. I will be using it for this experiment.

Step 2. Create a Hosted Zone in Amazon Route 53

Route 53 allows you to create a "Hosted Zone" which is a container where you will keep all your DNS records to define how you would like the traffic to route from the domain name and its subdomain names.

To create hosted zone:

Log in to your AWS account and click on "Services" and under "Networking and Content delivery" you will see "Route 53". Since Route 53 is a regional service, it can be accessed from any AWS region.

No alt text provided for this image
Figure: 3 Route 53 - Networking And Content Delivery

Next, click on the Hosted Zone and fill out the domain name, description, type, and Tags (optional). Since you want the domain to get the traffic from outside the VPC, select "Public hosted zone". Once you have the required information, click on "Create Hosted Zone".

No alt text provided for this image
Figure 4: Create Public Hosted Zone In Route 53

As soon as you create the public hosted zone for your domain, AWS Route 53 will add 2 records to it.

No alt text provided for this image
Figure: 5 Public Hosted Zone NS and SOA Records in Route 53

  • NS Record: It is the name server record, and it will list 4 name servers as "Authoritative Name Servers". The authoritative name servers store the most up-to-date information about the domain and their associated IPs and provide recursive resolvers with the final answer to the user queries.
  • SOA Record: It is called the Start of Authority record. It identifies the base DNS administrative information about the domain.

FYI, With Private Hosted Zone, you can use any domain name and you don't 
need to register a domain mainly because the domain is created under 
the "Private Hosted Zone" and traffic is only limited to your own VPC.        

If you want to read more about these records, click here.

Step 3. Update Name Servers and point them to AWS Name Servers

The final step is to update the default name servers on the domain registrar portal and point them to the AWS Route 53 public-hosted zone-provided name servers. The name servers that you see above in Figure: 5 are what you would need in this step. In my case, I bought this domain from Namecheap.com and I would go and update the name servers after logging into my user account.

No alt text provided for this image
Figure 6: Basic DNS Name Servers at Namecheap.com

Click on the dropdown and choose custom DNS and add 4 name server records from Route 53 public hosted zone.

No alt text provided for this image
Figure 7: Add Custom DNS Records

For easy access to name server names in AWS Route 53, open the public hosted zone of the domain and click CHECK BOX in front of the NS record as shown below, and copy the value by clicking the icon highlighted in "yellow" to avoid any typo error.

No alt text provided for this image
Figure 8: Public Hosted Zone Route 53 NS and SOA Records
No alt text provided for this image
Figure 9: Custom DNS From Route 53

As soon as you are done updating custom Name Servers, your domain will be pointed to the AWS Route 53 public hosted zone provided Name Server records.

Step 4. Verify Migration

To verify migration was performed successfully -

  • Check the propagation of the domain's Name Server using DNSChecker.org/ns-lookup. This change happens fairly quickly and just after you save your custom Name Servers from Route 53 in the domain registrar account, you would see that your domain is now pointing to AWS Route 53 Name Servers.

No alt text provided for this image
Figure 10: DNSChecker.org/ns-lookup.php

  • You can also check if your domain is resolved to the correct IP address through "WhatsMyDNS". This tool helps you perform the DNS lookup to check a domain name's current IP address and DNS record information against multiple nameservers in different parts of the world. Since we have not added any A record in the public hosted zone, DNS lookup won't show anything.

Scenario 2: Existing Domain from Third Party Web Host to AWS Route 53 Using DNS Zone File

If your website is currently hosted with a third-party hosting provider like HostGator or Bluehost, and you want to migrate only the DNS service to AWS Route 53 to take advantage of its benefits and ensure a seamless migration without losing any of your existing DNS records, you can make use of the existing DNS zone file from the cPanel of your current website hosting provider.

Some providers allow you to download the zone file directly from c-panel, but some might not have that option available like HostGator. If that's the case with your provider, then read the below article -

How to download DNS zone file from c-panel.

Once you have access to the DNS zone file then follow the below steps -

Import Existing DNS Zone File
Figure 11: Import Existing DNS Zone File

  1. Create a public hosted zone in Amazon Route 53 (See Step 2 above).
  2. Import the DNS zone file in Route 53 hosted zone using the import option as shown in Figure 11. In case of errors in importing the file, you can add those records manually also by clicking on "Create Record".
  3. Make sure all your DNS records are successfully migrated to Route 53 before moving on to the next step. Forgetting to add any records can result in website downtime.
  4. After verifying everything, update the domain name servers on the third-party hosting account (See Step 3 above).
  5. Verify Migration (See Step 4 above).

Next Steps:

Next, we will see how to host a public website from an S3 bucket utilizing CloudFront distribution and restricting public access to S3 origins by utilizing "Origin Access Control" settings. We will also see how to encrypt the connection between the client and the origin by enabling HTTPS using a free public SSL/TLS certificate from Amazon Certificate Manager (ACM).

Conclusion

Migrating DNS from a third-party provider to AWS Route 53 is a straightforward process, but it can be a bit confusing if you are unfamiliar with DNS services and how they are provided when you purchase a domain name. DNS is an additional service that comes bundled with a domain name or is offered by your web hosting provider, and it can be migrated. However, it is crucial to execute the migration carefully to prevent any potential downtime, especially if your website experiences high traffic.

To ensure a smooth transition, it is essential to pay close attention and ensure that all your DNS records are successfully transferred from your previous provider to AWS Route 53 before making any changes to the "Name Servers" currently associated with your domain. By taking these precautions, you can minimize the risk of disruptions and ensure a seamless DNS migration.

I hope you enjoy the read! Please let me know if you have any questions in the comments and please share your experience specifically related to downtime and disruptions during the migration process. Thank you!

Sodeeq Elusoji

Building and Managing Engineering Teams

3 个月

Great article Harry S. For anyone reading this, if you copy the DNS value from Route53 and you try to update it in your domain provider's DNS record but it fails, ensure that the trailing dot(.) at the end of the DNS value is also part of the value you copied.

回复
José María Rivera

Profesional de Servicios y tecnologías de la información

1 年

Harry S. "Hello! For Scenario 1, is the name of the hosted zone in Route 53 required to match the domain (example.com in your case)?

要查看或添加评论,请登录

Harry S.的更多文章

社区洞察

其他会员也浏览了