Reputation: 930
I have a hosted zone and record set that route to multiple addresses. I'd like to update the record set with adding or removing one IP address in the list. How to do that with AWS CLI (API)? I tried with this json request below but it replaced the exiting list with the new one (not update)
{
"Comment": "Update the A record set",
"Changes": [
{
"Action": "UPSERT",
"ResourceRecordSet": {
"Name": "mydomain.com",
"Type": "A",
"TTL": 300,
"ResourceRecords": [
{
"Value": "4.4.4.4"
}
]
}
}
]
}
It replaced all IP addresses with 4.4.4.4. I expect it updates 4.4.4.4 to existing IP addresses.
Upvotes: 2
Views: 4031
Reputation: 181
You can add multiple IP addresses into your json like this:
{
"Comment": "Update the A record set",
"Changes": [{
"Action": "UPSERT",
"ResourceRecordSet": {
"Name": "mydomain.com",
"Type": "A",
"TTL": 300,
"ResourceRecords": [{
"Value": "54.204.140.57"
},
{
"Value": "54.175.56.142"
}
]
}
}]
}
You can query your hosted zone records like this:
aws route53 list-resource-record-sets --hosted-zone-id {ZONEID} --query "ResourceRecordSets[?Type == 'A']"
which would return a json message like:
[
{
"Name": "mydomain.com.",
"Type": "A",
"TTL": 300,
"ResourceRecords": [
{
"Value": "54.204.140.57"
}
]
},
{
"Name": "mydomain.com.",
"Type": "A",
"TTL": 300,
"ResourceRecords": [
{
"Value": "54.175.56.142"
}
]
}
]
Upvotes: 1
Reputation: 4501
DNS changes will take time to propagate for one thing.
Your changes to resource record sets take time to propagate to the Amazon Route 53 DNS servers. Currently, the only way to verify that changes have propagated is to use the GetChange API action. Changes generally propagate to all Amazon Route 53 name servers in a couple of minutes. In rare circumstances, propagation can take up to 30 minutes.
http://docs.aws.amazon.com/Route53/latest/DeveloperGuide/resource-record-sets-editing.html
You can try your changes in the AWS route53 CLI
aws route53 change-resource-record-sets --hosted-zone-id <value> --change-batch <JSON doc>
This will return an ID that you can query status on with
Id -> (string) The ID of the request.
aws route53 get-change --id <value from previous cli>
This will return the status of the change
Status -> (string) The current state of the request. PENDING indicates that this request has not yet been applied to all Amazon Route 53 DNS servers.
PENDING indicates that the changes in this request have not replicated to all Amazon Route 53 DNS servers. This is the initial status of all change batch requests.
INSYNC indicates that the changes have replicated to all Amazon Route 53 DNS servers.
http://docs.aws.amazon.com/cli/latest/reference/route53/get-change.html
http://docs.aws.amazon.com/cli/latest/reference/route53/change-resource-record-sets.html
Upvotes: 0