01 Run create-hosted-zone command (OSX/Linux/UNIX) to create a new Route 53 hosted zone. The following command example creates a new hosted zone for a domain name called myawsdomain.com:
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
aws route53 create-hosted-zone
--name myawsdomain.com
--caller-reference 2016-05-08-18:45
--hosted-zone-config Comment="Public DNS hosted zone for myawsdomain.com"
02 The command output should return the new hosted zone metadata (including the zone ID - highlighted):
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
{
"HostedZone": {
"ResourceRecordSetCount": 2,
"CallerReference": "2016-05-08-18:45",
"Config": {
"Comment": "Public DNS hosted zone for myawsdomain.com",
"PrivateZone": false
},
"Id": "/hostedzone/Z326VIKTTL6ACZ",
"Name": "myawsdomain.com."
},
"DelegationSet": {
"NameServers": [
"ns-1329.awsdns-38.org",
"ns-608.awsdns-12.net",
"ns-1842.awsdns-38.co.uk",
"ns-490.awsdns-61.com"
]
},
"Location": "http://route53.amazonaws.com/hostedzone/Z326VIKTTL6ACZ",
"ChangeInfo": {
"Status": "PENDING",
"SubmittedAt": "2016-05-07T10:39:31.137Z",
"Id": "/change/C2MW22PIPINF09"
}
}
03 In order to add a DNS record to the newly created hosted zone, you must create first a Route 53 change file (in this case a JSON file named cname-record-set.json) to declare the new DNS record set. The following example describes a CNAME record definition for a domain name called myawsdomain.com (to create other types of DNS records using AWS CLI, check the record set syntax provided by AWS at http://docs.aws.amazon.com/cli/latest/reference/route53/change-resource-record-sets.html):
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
{
"Comment": "CNAME record set for myawsdomain.com hosted zone.",
"Changes": [
{
"Action": "CREATE",
"ResourceRecordSet": {
"Name": "api.myawsdomain.com.",
"Type": "CNAME",
"TTL": 86400,
"ResourceRecords": [
{
"Value": "myawsdomain.com"
}
]
}
}
]
}
04 Run change-resource-record-sets command (OSX/Linux/UNIX) using the hosted zone ID returned at step no. 2 and the Route 53 change file (cname-record-set.json) as command parameters:
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
aws route53 change-resource-record-sets
--hosted-zone-id Z326VIKTTL6ACZ
--change-batch file://cname-record-set.json
05 The command output should return the new DNS record set metadata. The record set status should be PENDING at this moment:
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
{
"ChangeInfo": {
"Status": "PENDING",
"Comment": "CNAME record set for myawsdomain.com hosted zone.",
"SubmittedAt": "2016-05-07T10:43:21.663Z",
"Id": "/change/CW22QA2MN6TUN"
}
}
06 Run get-change command (OSX/Linux/UNIX) using the Route 53 change file ID returned at the previous step to get the current status for the newly added record set:
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
aws route53 get-change
--id CW22QA2MN6TUN
07 The command output should return the current status of the DNS record batch request. The current status should be set to INSYNC which indicates that the change was fully propagated to all AWS Route 53 DNS server nodes:
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
{
"ChangeInfo": {
"Status": "INSYNC",
"Comment": "A new record set for the zone.",
"SubmittedAt": "2013-12-06T00:00:00.000Z",
"Id": "/change/CHANGEID123"
}
}
08 Repeat steps no. 1 – 7 for each domain name that you want to manage with AWS Route 53 DNS service.