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?
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?