Building a Simple, Secure Website in AWS with a Godaddy Domain Name, Part 2

Jonathan Stock
Coding in the Cloud
8 min readJun 14, 2020

Configuring DNS with GoDaddy and Route 53

In the prior tutorial, you set up all the “stuff” in the cloud to host a website — a domain name registered through GoDaddy, an AWS server to store your files, and a simple static HTML website. In this tutorial, we’ll configure DNS to so that anyone can find your amazing but simple website by simply entering in your domain name.

Think of DNS as an invisible Internet directory. It allows anyone with a browser on an Internet-connected computer to enter a website domain name, connect to a remote server and download the digital files — from anywhere in the world. Here’s how DNS works. To learn more see this video by DNS Explained.

Domain Name System (DNS) — Each computer that connects to the Internet must have a unique IP address. IP addresses are a series of numbers like 506.457.14.514. Just like you search for a telephone number in your smartphone by looking up your friend’s name, the DNS or domain name system, enables you to search for a website’s IP address by its domain name. So instead of entering 506.457.14.514, we just type example.com and the domain name system tells our computer to go to IP address 506.457.14.514.

Nameserver: The nameserver identifies a set of servers any request should reference in order to obtain a domain’s DNS records. When you register your domain through GoDaddy, GoDaddy automatically assigns it’s own nameservers and allows you to specify the IP address for your website host.

When you register your domain name through GoDaddy, it doesn’t have an IP Address in the A record field yet, so the value of the A record is “parked” at GoDaddy. The @ symbol indicates that the hostname (in this case www) should point to the naked domain and use its value. That value, as indicated above shows “parked” because I haven’t assigned a value yet. This ensures that requests for both example.com and www.example.com, resolve to the same location.

Alias Record: Alias records are a category of records in a DNS configuration. In the image above, the A record and CNAME are examples of Alias records.

SO Record: Start of Authority. Every domain must have a Start of Authority record at the cutover point where the domain is delegated from its parent domain. When you create a hosted zone for your domain in Route 53 or any authoritative DNS provider such as GoDaddy, it automatically creates an SOA record. You won’t be configuring or changing this record. It’s just an FYI.

Why not just Update GoDaddy with the AWS S3 IP Address?

Normally you would simply update the GoDaddy A record with the IP address of your host and our work here would be finished. But because we are using AWS S3 to host the website, which doesn’t offer a static IP address, we have to build a workaround.

AWS has its own in-house DNS service called Route 53. And since it is built into the AWS cloud, it’s a bit smarter when it comes to AWS services. For example, you can tell AWS Route 53 to point to your S3 bucket, and even though S3 buckets don’t have a static IP address, Route 53 knows where to find it everytime.

So, to make it all work on AWS S3, we have to change our DNS nameservers from GoDaddy to AWS. This just means that AWS will manage the DNS, not GoDaddy. In step It’s easy to change it back and forth.

Step 1: Create a hosted zone in R53

We’ll be configuring Route 53 as noted in this AWS Reference Doc for simple DNS configurations. It works If you’re routing internet traffic for just a few subdomains to a small number of resources, such as web servers or Amazon S3 buckets.

  1. In the AWS console, navigate to Route 53
  2. Select DNS management Get Started Now
  3. Select Create Hosted Zone
  4. Enter the domain name you registered in GoDaddy such as example.com
  5. Under Type, select dropdown as Public Hosted Zone
  6. Select Create

Step 3: Update TTL in Route 53

TTL: Time to live. Pronounced time to “live” as in “live or die”. TTL is the numerical value, in seconds, of how long a DNS record will be cached before it needs to be refreshed. Whenever a nameserver is queried for a DNS record, it will check to see if it has delivered that same DNS record within the time period specified by the TTL and if so, will deliver the cached version of that DNS record. Source

Having a longer TTL keeps the record in cache longer, which means a user who is requesting the website doesn’t have to go back to the root server and look it up everytime. So if you are running a large ecommerce or other major website, it makes sense to have a longer TTL so your users get the fastest experience possible. But if you are making DNS changes, you should lower the TTL until you are finished so that in case you need to change something, the DNS system will reflect those updates quickly and you don’t have to wait around for hours.

The default TTL for R53 nameservers was 48 hours. Since we are making changes in the DNS system for this tutorial change it to 300 seconds.

Step 2: Update name servers in GoDaddy

In this step we will configure GoDaddy to let Route 53 take over management of the nameservers. After this step is completed GoDaddy will still be the registrar, but Route 53 will be the authoritative DNS nameserver and will control the routing instructions for your domain across the entire DNS system.

  1. Navigate back to Route 53

2. Select the nameservers

3. Copy the nameserver values

4. Navigate back to GoDaddy DNS Management page

5. Select Nameservers > using default nameservers> Change

6. Select Enter my own nameservers (advanced)

7. Paste in the AWS Route 53 nameservers under ‘Enter my own nameservers’. If you need to add a new line select ‘add nameserver’.

8. Select save

GoDaddy reminds you that it may take some time for these updates to be processed. This is thanks to the 1 hour default TTL. The TTL specifies how long the DNS settings will remain cached in the DNS servers for your domain. GoDaddy’s nameserver default is 1 hour. Once you change the nameservers to Route53, it will take up to 1 hour for this change to be reflected in the DNS system. So just keep this in mind when you are doing this tutorial. One you make the changes, you may need to take a break and come back until the DNS servers have updated with your new changes.

Step 3: Create a ‘A’ Record for example.com

Now that Route 53 controls the routing for your domain, you can now create the routing rules to point requests for your domain to the static website you are hosting in an S3 bucket. In the Route 53 hosted zone, you can now create records that define where you want to route traffic for a domain (example.com) or subdomain (www.example.com).

Since you want users that enter both example.com and www.example.com to find your website, you create two A records in Route 53, one named example.com and the other named www.example.com. In each record, you specify the IP address of the Amazon S3 bucket for the website you created in the previous tutorial.

An A record is a type of alias record: Alias records let you route traffic to selected AWS resources, such as an Amazon S3 bucket. When Route 53 receives a DNS query for an alias record, Route 53 responds with the applicable value for that resource. In this tutorial it will route to the Amazon S3 bucket that is configured as a static website — Route 53 responds with one IP address for the Amazon S3 bucket.

Another type of A record is a CNAME. In the next tutorial we’ll create a CNAME in Route 53 that routes requests to a CloudFront distribution. Why would you want to do this? Check out the next tutorial and we’ll show you all the advantages of using a CDN, or Content Delivery Network, in front of your website. For more info including CNAMEs see Choosing Between Alias and Non-Alias Records

For your information a list of possible alias types are in this article: Values for Alias Records. This article specifies the alias record configuration instructions provided by Amazon for an Amazon S3 bucket

  • The name of the record must match the name of your Amazon S3 bucket. For example, if the name of your bucket is acme.example.com, the name of this record must also be acme.example.com. (go back to S3 if needed and confirm the name of your S3 Bucket)
  • In addition, you must configure the bucket for website hosting. For more information, see Configure a Bucket for Website Hosting in the Amazon Simple Storage Service Developer Guide. (we did this in the prior tutorial)
  1. Go to Route 53 and select the hosted zone you created in step 2
  2. Select ‘create a record set

3. Under ‘Create Record Set’

4. Name: leave it blank (it auto-magically populates based on the domain of your hosted zone)

5. Type: A — IPV4 address

6. Alias: Yes

7. TTL: 300 seconds

8. Alias Target: Under ‘S3 website endpoints’ AWS auto-maigically populates the S3 bucket you created in the prior step using the domain name of your site.

9. Routing policy: Simple

10. Select update

Step 4: Create ‘A’ Record for www.example.com (separate record for www)

  1. Repeat the prior step

2. Add the ‘www’ prefix to the record set name.

Step 5: Test your website

  1. Enter your-domain.com
  2. Enter www.your-domain.com

In part 3 we’ll configure AWS CloudFront to provision an SSL/TLS certificate and deliver your website securely with HTTPS.

The following excellent sources provide more details about DNS concepts and how it works.

DNS Management: Registrars and Nameservers

DNS Simple: What is an A Record

DNS Management: Record Types and When To Use Them

Domain Registrar or DNS Hosting: The Difference Explained

--

--