Services >> Cloud >> AWS >> CLI >> How to update route53 record in your hosted zone

e.g.

hosted zone: example.com


To update the IP address of your DNS A record for server.example.com with the IP addr 11.22.33.44 

 

(1) Obtain the route53 hosted-zone-id

aws route53 list-hosted-zones

Example output:

{
    "HostedZones": [
        {
            "ResourceRecordSetCount": 4,
            "CallerReference": "C510CAC3-D5D9-XXXX-B039-1DFA2XXXXXXX",
            "Config": {},
            "Id": "/hostedzone/Z1W9BXXXXXXXLB",
            "Name": "example.com."
        }
    ],
    "IsTruncated": false,
    "MaxItems": "100"

} 

Note the hosted zone id, e.g. above highted in RED

(2) prepare the recordset .json file e.g.

/tmp/update.json

{
    "Comment": "Update record to reflect new IP address of home router",
    "Changes": [
        {
            "Action": "UPSERT",
            "ResourceRecordSet": {
                "Name": "server.example.com.",
                "Type": "A",
                "TTL": 300,
                "ResourceRecords": [
                    {
                        "Value": "11.22.33.44"
                    }
                ]
            }
        }
    ]
}

(3) run the aws cli to update

aws route53 change-resource-record-sets --hosted-zone-id Z1W9BXXXXXXXLB --change-batch file:///tmp/update.json