Skip to content

Instantly share code, notes, and snippets.

@thom4parisot
Forked from dfox/update-route53-dns.sh
Created November 15, 2012 11:49
Show Gist options
  • Save thom4parisot/4078250 to your computer and use it in GitHub Desktop.
Save thom4parisot/4078250 to your computer and use it in GitHub Desktop.
A script to update DNS on Route 53
#!/bin/sh
# Make sure only root can run our script
if [ "$(id -u)" != "0" ]; then
echo "This script must be run as root" 1>&2
exit 1
fi
# Load configuration
. /etc/route53/config
# Export access key ID and secret for cli53
export AWS_ACCESS_KEY_ID
export AWS_SECRET_ACCESS_KEY
# Use command line scripts to get instance ID and public hostname
INSTANCE_ID=$(ec2metadata --instance-id)
PUBLIC_IP=$(ec2metadata --public-ip)
# Replace the A Zone (because initially created as a A record from template – throws an exception otherwise)
cli53 rrcreate "$ZONE" "$INSTANCE_ID" A "$PUBLIC_IP" --replace --ttl "$TTL"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment