Engine Yard Blog RSS Feed

Pop quiz, which URL is prettier:

  1. http://emrubyconf.com/
  2. http://ec2-50-19-107-187.compute-1.amazonaws.com/
Exactly, the first one. To setup a custom domain name you need to buy a domain and then register DNS records to point to your AppCloud cluster. This is (to me) a convoluted process. It could be much simpler.

Introducing the ey-dns command line application to make DNS simple (see the readme). It supports 6 different DNS services, including DNSimple and AWS Route 53 (see below).

It's really quite easy to use:

  1. Install the tool:

    
    $ gem install engineyard-dns
    
    
    
    
  2. Change to your Rails/Ruby project that is deployed with AppCloud:
    
    $ cd path/to/my/app
    
    
    
    
  3. Run `ey-dns`:
    
    $ ey-dns assign myapp.com
    Assigning myapp.com —> 1.2.3.4 (drnic/myapp_production)
    Assigning www.myapp.com —> 1.2.3.4 (drnic/myapp_production)
    
    
    
If you have previously assigned the domain records to another IP address, it will prompt you to change them. If there is any confusion about which AppCloud environment is hosting your application, it will show you your options and then you can use the `--environment` and `--account` options to be more specific:

$ ey-dns assign myapp.com --environment myapp_production


(Subdomains are a little weird because of how DNS zones work. Put your bare domain first and then subdomain names after. The following sets staging.myapp.com to the myapp_staging environment.

)

$ ey-dns assign myapp.com staging --environment myapp_staging


If you have multiple apps on one environment, you will still have to update the domain name of each app in the AppCloud dashboard so that nginx knows what vhost you mean to serve at that domain. Just click edit on each app in an environment to add vhost domains.

Preparing your DNS provider

To be complete you will also need to purchase/transfer a domain:

  1. Register your application's domain with a DNS provider (see supported list below), such as DNSimple.
  2. Transfer your domain to your DNS provider or change to use their name servers, such as ns1.dnsimple.com (ns2, ns3, etc) for DNSimple.

Supported DNS providers

ey-dns will automatically determine which DNS provider is managing the domain/zone that you are wiring up to your AppCloud environment.

This new CLI uses fog to access DNS providers. The current list of available DNS providers for fog is: AWS, Bluebox, DNSimple, Linode, Slicehost, Zerigo. The next section shows how to setup fog credentials.

DNS credentials

To access your DNS provider, you need to add your account/API credentials into your ~/.fog file.

In my example ~/.fog file below I have DNS access to DNSimple, Slicehost and AWS Route 53.


:default:
  :dnsimpleemail:        MYEMAIL
  :dnsimplepassword:     XXXXXXXXXXX
  :awsaccesskeyid:     0NJRCXXXXXXXXXXXX
  :awssecretaccesskey: QGtnbXXXXXXXXXXXX/qQ4lXXXXXXXXXXXXXX
  :slicehost_password:    f9a265f66XXXXXXXXXXXXXXXXXXXXXXXXXXX

DNSimple credentials

I currently use DNSimple for registering and serving all my new domains. Their API credentials are the same email/password you use to login to the service.

Note the surreptitious referral used here, giving me a free month for each DNSimple sign-up, bwhahahaha. To avoid gifting me a free month, use http://dnsimple.com link. A free month isn't as cool as free swag, but I don't think DNSimple has free swag. Well, I don't have any of it.

AWS credentials

Recently AWS began offering an API-driven DNS server Route 53. The AWS credentials for access DNS are the same credentials you use in CarrierWave or PaperClip to access AWS S3. To find them, log into your AWS Account and navigate to “Security Credentials”, then “Access Credentials”, and click “Show” to see your secret access key.

Slicehost credentials

Until I switched to DNSimple and to fog, I used Slicehost for its API/CLI-driven DNS. I still have many domains managed by Slicehost. To enable API access to your Slicehost account in fog (and hence ey-dns) go to https://manage.slicehost.com/api, enabled API access and copy your API token into the slicehost_password field of ~/.fog above.

Testing credentials

You can test your DNS credentials with the ey-dns domains command:


$ ey-dns domains
AWS: none
DNSimple:
  drnicwilliams.com - 0 records
  emrubyconf.com - 2 records
  mocra.com - 27 records
Slicehost:
  myconfplan.com. - 0 records

Summary

Hopefully this tool makes it much easier to setup or change DNS for your AppCloud environments. Let us know in the comments or in the project's Issues if you love it, find bugs or have feature requests.

The source and instructions for the project is available on GitHub.


Tagged:

comments powered by Disqus