Hands-On: Create a Record

Add or update a DNS record from the CLI with a change batch.

1 min read

Changes to records are sent as a change batch with an action: CREATE, DELETE, or UPSERT (create or update). Save this as change.json:

Try it

change.json
{
  "Comment": "Point api.notesnap.app at our server",
  "Changes": [{
    "Action": "UPSERT",
    "ResourceRecordSet": {
      "Name": "api.notesnap.app",
      "Type": "A",
      "TTL": 300,
      "ResourceRecords": [{ "Value": "54.210.33.17" }]
    }
  }]
}
Terminal
# Find your hosted zone ID
aws route53 list-hosted-zones-by-name --dns-name notesnap.app

# Apply the change
aws route53 change-resource-record-sets           --hosted-zone-id Z0123456789ABCDEFGHIJ           --change-batch file://change.json

# Check what the world sees
dig +short api.notesnap.app

The response shows "Status": "PENDING", which turns INSYNC once all Route 53 servers have the change, usually within a minute.

Note

If you bought the domain elsewhere, point the domain's name servers (at your registrar) to the four NS records Route 53 shows for your hosted zone. Until you do, your Route 53 records aren't used.

Key takeaways

  • Record changes are change batches with CREATE, DELETE, or UPSERT actions.
  • Use dig (or nslookup) to verify what resolvers return.
  • Domains registered elsewhere must use Route 53's name servers.

Check your understanding

Pick an answer to see the explanation.

  1. 1. Which action creates a record if it's missing and updates it if it exists?