0

I have a number of Amazon EC2 instances, all running Ubuntu, which I'd like to configure to use Amazon's Route 53.

I setup a script, following Shlomo Swidler's article, but ran into script-related issues, which were answered here. Now, I have the script working, but the only CNAMES being added to Route 53 by the script are the Amazon instance IDs (i-abcd1234.mydomain.com).

According to Swidler's article, the script allows Route 53 to pickup a "ShortName" tag, giving each instance a "friendly" CNAME. I have ShortName tags added to all my instances, but they haven't been picked up by Route 53.

Here's my script:

#!/bin/tcsh -f

set root=`dirname $0`
setenv EC2_HOME /usr/lib/ec2-api-tools
setenv EC2_CERT /etc/cron.route53/ec2_x509_cert.pem
setenv EC2_PRIVATE_KEY /etc/cron.route53/ec2_x509_private.pem
setenv AWS_ACCESS_KEY_ID myaccesskeyid
setenv AWS_SECRET_ACCESS_KEY myaccesskey

/usr/bin/ec2-describe-instances | \
perl -ne '/^INSTANCE\s+(i-\S+).*?(\S+\.amazonaws\.com)/ \
and do { $dns = $2; print "$1 $dns\n" }; /^TAG.+\sShortName\s+(\S+)/ \
and print "$1 $dns\n"' | \
perl -ane 'print "$F[0] CNAME $F[1] --replace\n"' | \
xargs -n 4 /etc/cron.route53/cli53/cli53.py \
rrcreate -x 60 mydomain.com

Has anyone else tried this? What could be preventing Route 53 from picking up the "ShortName" tags?

1 Answer 1

1

The script appears to work in my environment. It's most likely a mismatch between the output of ec2-describe-instances and the perl code in the script you've posted.

The simplest possibility would be if the case in your tag name doesn't match that specified by the script. The script you posted requires "ShortName" with capital S and capital N. "Shortname" and "shortname" won't match.

Another possibility is that your ec2-api-tools are of a version prior to 2010-08-31 when tag awareness was added. In that case, the lines starting with "TAG" won't show up, and so this script won't see them. If you aren't using Ubuntu 10.10, the default ec2-api-tools package will not have this latest code. Your best bet in that case is just to download the latest version from the official EC2 API tools download page.

If neither of these is the problem, can you give us some sample output of /usr/bin/ec2-describe-instances <instance-id> for one instance you're having trouble with?

3
  • Thanks for responding. My tags do match the case of whats in the script, "ShortName". However, I'm running Ubuntu 10.04, so out of date ec2-api-tools is most likely my problem.
    – ks78
    Feb 15, 2011 at 17:02
  • If you run the script above removing everything after "ec2-describe-instances" (from the | character on), you can see whether the "TAG" lines are getting displayed or not. If you do download the tools, you should be able to use the same script, just update the EC2_HOME variable and replace "/usr/bin" with the path to where you extract the zip file. Good luck.
    – daveadams
    Feb 15, 2011 at 19:42
  • That was it. I updated my ec2-api-tools and now it works! Thanks again for your help.
    – ks78
    Feb 16, 2011 at 6:27

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .