Skip to content

Amazon EC2

How to Point a Domain to an Amazon EC2 Virtual Server

Previously, in our continuing discussion of Amazon Elastic Cloud Computing (EC2), I showed how to set up a simple EC2 virtual server, and how to host basic content (HTML pages) using Apache. This week, I’ll examine how to configure a domain name to point to your server. Fortunately, compared to everything we’ve done so far, this is a relatively simple task. I’ll finish with a quick discussion of Route 53, Amazon’s new domain name server.

Elastic IPs

When the EC2 service first premiered, each EC2 server was assigned a dynamic IP. If a server had to be restarted, it was given a new dynamic IP. Obviously, this makes mapping a domain name to a server problematic, as the DNS association between the domain name and the server IP would be invalidated with every server restart.

To overcome this problem while still retaining the reliability and scalability of cloud computing, Amazon introduced the notion of Elastic IPs. An Elastic IP is a static IP address that belongs to your Amazon EC2 account, as opposed to a specific server. You can associate an IP address to a virtual server; if you need to take that server down for any reason, you can associate the IP with one of your other virtual servers.

Amazon doesn’t charge money for requesting Elastic IPs, but does charge a nominal fee for any unmapped Elastic IPs. To receive a new Elastic IP, simply go to Elastic IPs on the EC2 screen, and click Allocate New Address.

You can then select the newly assigned IP and click Associate to assign it to your EC2 instance. The Elastic IP should be mapped to your virtual server within minutes.

Mapping an Elastic IP to a Domain Name

Once you’ve allocated an Elastic IP to your EC2 server, mapping it to a domain is simple: just modify your domain’s A record with your domain name registrar to point to the Elastic IP. If you have your domain registered with GoDaddy, for example, you can go to the GoDaddy DNS Manager, select Edit Zone for your domain, and put the Elastic IP in the box provided for the A record.

As with most DNS changes, you may need to wait up until 24 hours for old DNS records to expire before the domain name successfully maps to your EC2 server.

Using Route 53 for Dynamic DNS Configuration

As I was researching this article, Amazon announced its new Route 53 domain name service, which allows both configuration and lookup of DNS records using a REST-based API.

I was hoping at the time that Amazon announced it that there would be great UI support for Route 53. It should be possible, for example, to go to the EC2 Dashboard, map the domain to an Elastic IP address, and receive from Amazon a list of nameservers to provide to your domain registrat. Unfortunately, such Dashbaord support is currently lacking. Early adapters must use the REST API, which involves:

  • Generate a CreateHostedZoneRequest XML file;
  • Create an access key to validate your EC2 account with the API;
  • Submit the DNS request to Route 53 using a Perl script (; and
  • Configure your domain registrar to use the domain name servers returned by Route 53 in the previous step.

Hopefully, in the future, Amazon will provide excellent Dashboard support for Route 53. Until then, unless you need to develop a set of tools to manage a complex network of EC2 virtual servers, changing your registrar’s A record will likely be all you need.

Be Sociable, Share!
    The following two tabs change content below.

    5 Comments (Add Yours)

    1. Thanks for the quick tutorial! It along with Dave Winer’s ec2 for poets helped to get my server up and running and mapped to a domain. Next step is to try with Windows Azure and see if I can sort out the steps myself!

    2. Hi,

      I have a webapplication running on amazon EC2. I have managed to change the DNS to the EC2 ip address but my webapplication has URL like http://servername/sites/Pages. now my domain routes me to root page that is http://servername/.

      How can i add this folder paths? Any Idea?



      • (1) Quick and dirty solution, which may work depending on how your application makes any references to other parts of the site…
        Create a very simple index.html in the web root which uses the tag to immediately (after 0 seconds) to ‘refresh’ the page, specifying a different URL (the one for your application)

        (2) Specify the web root directory (or a new virtual host, which is effectively the host’s name and web root directory, if you have more than one site being served by the web server) in the web server (e.g. Apache) configuration file.
        This is just a few lines in a configuration file in Apache which says something like… for ‘this’ host name use ‘this directory’ as the root directory.
        You can find examples with a quick Google search.

        • ‘which uses the tag’
          should have said ‘which uses the META tag’
          (but the editor stripped out the original ‘meta’ because I’d enclosed it in angle-brackets – guess it strips out HTML).

    3. Great tutorial. This is even better than Amazon’s own documentation…!

    Add Your Comment (Get a Gravatar)