Nov 052017
 
AWS - Route53 and your own IP

AWS is functionally very nice, but the docs are…improvable. Thus the need for me to write down things which should be simple but are not:

Updating DNS Records

Very easy to do in the GUI. Tricky the first time you try this from the aws CLI.

I got a delegated zone aws.XXX. (I own XXX and i delegated aws.XXX. to AWS Route53) and when I boot my (special) EC2 instance, I’d like it to update the DNS record ec2.aws.XXX. accordingly.

Here the needed batch file (stored in the file “dnsupdate.json”)

{ 
  "Comment": "Updating my EC2 instance DNS record", 
  "Changes": [ 
    { 
      "Action": "UPSERT", 
      "ResourceRecordSet": { 
        "Name": "ec2.aws.XXX.", 
        "Type": "A", 
        "TTL": 300, 
        "ResourceRecords": [ 
          { 
            "Value": "34.207.167.92" 
          } 
        ] 
      } 
    } 
  ] 
}

Pitfall 1: “Name” is the full FQDN. Get your current IP via

curl http://169.254.169.254/latest/meta-data/public-ipv4

Then update via aws CLI:

aws route53 change-resource-record-sets --hosted-zone-id Z1KXXXXXXXXXX \
--change-batch file:///home/ec2-user/dnsupdate.json

Pitfall 2: The batch file location MUST NOT be the simple “dnsupdate.json” but it MUST BE “file://absolute/path/to/the/file.json”. Otherwise you get the totally unhelpful error message

aws route53 change-resource-record-sets --hosted-zone-id Z1KXXXXXXXXXX \
--change-batch dnsupdate.json                        

Error parsing parameter '--change-batch': Expected: '=', received: 'EOF' for input: 
dnsupdate.json 
               ^