Menu
Getting Started with AWS
Hosting a Static Website

Step 5 (Optional): Associate a Domain Name with Your Website

The easiest way for your customers to access your website is through a memorable domain name. In the procedures on this page, replace example.com with your domain name. If you haven't done so already, register your domain name.

A Domain Name System (DNS) web service routes visitors to websites by translating domain names (such as www.example.com) into the numeric IP addresses (such as 192.0.2.1) that computers use to connect to each other.

You can use your DNS service, such as your domain registrar, to create a CNAME record to route queries to your static website. For more information, see the documentation for your DNS service.

Alternatively, you can use Amazon Route 53 as your DNS service. It is designed to be highly available, scalable, and cost effective. To associate a domain name with your website using Amazon Route 53, complete the following tasks.

Create a Hosted Zone for Your Domain

A hosted zone is a container for the information about how you want to route traffic on the Internet for a domain (such as example.com) and its subdomains (such as www.example.com).

To create a hosted zone

  1. Open the Amazon Route 53 console at https://console.aws.amazon.com/route53/.

  2. If you are new to Amazon Route 53, you see a welcome page; choose Get Started Now for DNS Management. Otherwise, choose Hosted Zones in the navigation pane.

  3. Choose Create Hosted Zone.

  4. For Domain Name, type your domain name.

  5. Choose Create.

Create Record Sets for Your Domain and Subdomain

Create an alias resource record set that routes queries for your domain name to the Amazon S3 domain name for your bucket.

To configure the alias record set for your root domain

  1. On the Hosted Zones page, choose the hosted zone that you created for your domain.

  2. Choose Go to Record Sets.

  3. Choose Create Record Set.

  4. For Create Record Set, do the following:

    1. Leave the default name, which is the root domain.

    2. For Type, choose A — IPv4 address.

    3. For Alias, choose Yes. An alias enables Amazon Route 53 to associate your domain name with the Amazon S3 bucket that you configured as a website endpoint.

    4. Choose Alias Target. Choose your root domain website endpoint from the list (for example, example.com). Do not select the www subdomain endpoint (for example, www.example.com).

    5. For Routing Policy, choose Simple.

    6. Leave Evaluate Target Health set to No.

    7. Choose Create.

Next, you create an alias resource record set, which routes queries for your www subdomain name to the Amazon S3 domain name for your bucket.

To configure the alias resource record set for your www subdomain

  1. On the Hosted Zones page, select the hosted zone that you created for your domain.

  2. Choose Go to Record Sets.

  3. Choose Create Record Set.

  4. For Create Record Set, do the following:

    1. For Name, type www. The root domain is already specified for you, and the connecting period (.) appears when you start typing.

    2. For Type, choose A — IPv4 address.

    3. For Alias, choose Yes.

    4. Choose Alias Target. Select your www subdomain website endpoint from the list (for example, www.example.com). Do not select the root domain endpoint (for example, example.com).

    5. For Routing Policy, choose Simple.

    6. Leave Evaluate Target Health set to No.

    7. Choose Create.

(Optional) Set Up a DNS Provider

If you registered a new domain name and have used that name while doing this tutorial, you're ready to set up Amazon Route 53 as your DNS provider.

Alternatively, if you're reusing a domain name that was previously associated with another website, you might need to transfer other DNS records from your current DNS provider to Amazon Route 53 in order to ensure the continued availability of the services hosted under the domain name. To determine which DNS records you must replicate in Amazon Route 53, check the DNS record settings configured for the domain in your current DNS provider. Two records that you should not transfer to Amazon Route 53 are the Start of Authority (SOA) and Name Server (NS) records. These records were set by Amazon Route 53 when the name servers were allocated, and they should not be changed.

First, log into the domain name registrar that you used to register your domain name. Use the web interface provided by the registrar to set the name servers for your domain to the name server values displayed under Name Servers in the details for the hosted zone. How you do this depends on the registrar that you used.

Then, wait 2 to 48 hours for the Internet DNS resolver network to propagate name server changes. To see if the name server change has gone through, use a command line utility such as dig (for Mac OS X, Unix, or Linux) or nslookup (for Windows). The following example shows how use dig to see which name servers are associated with your domain.

dig example.com

When the output shows AUTHORITY SECTION values that are the AWS name servers that you allocated using Amazon Route 53, as in the following example, the DNS changes have propagated through the DNS resolver network.

;; AUTHORITY SECTION:
example.com.	118928	IN	NS	ns-806.awsdns-36.net.
example.com.	118928	IN	NS	ns-1456.awsdns-54.org.
example.com.	118928	IN	NS	ns-1713.awsdns-22.co.uk.
example.com.	118928	IN	NS	ns-105.awsdns-13.com.

After your DNS changes have propagated, you can view your website using your custom domain name.

If you open your www subdomain (such as www.example.com) in your web browser, the browser is redirected to your domain (such as example.com).