Amazon Route 53 via Command Line

Retrieve a list of hosted zones:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
$ aws route53 list-hosted-zones
{
"HostedZones": [
{
"ResourceRecordSetCount": 4,
"CallerReference": "12345678-ABCD-EFGH-IJKL-ABCDEFGHIJKL",
"Config": {},
"Id": "/hostedzone/1234567890ABC",
"Name": "realguess.net."
}
],
"IsTruncated": false,
"MaxItems": "100"
}

Get a single hosted zone with delegation set (four Route 53 name servers that were assigned to the hosted zone):

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
$ aws route53 get-hosted-zone --id 1234567890ABC
{
"HostedZone": {
"ResourceRecordSetCount": 4,
"CallerReference": "12345678-ABCD-EFGH-IJKL-ABCDEFGHIJKL",
"Config": {},
"Id": "/hostedzone/1234567890ABC",
"Name": "realguess.net."
},
"DelegationSet": {
"NameServers": [
"ns-1727.awsdns-23.co.uk",
"ns-1312.awsdns-36.org",
"ns-402.awsdns-50.com",
"ns-587.awsdns-09.net"
]
}
}

List all resource record sets in a hosted zone:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
$ aws route53 list-resource-record-sets --hosted-zone-id 1234567890ABC
{
"IsTruncated": false,
"ResourceRecordSets": [
{
"ResourceRecords": [
{
"Value": "192.168.153.123"
}
],
"Type": "A",
"Name": "realguess.net.",
"TTL": 172800
},
{
"ResourceRecords": [
{
"Value": "ns-1727.awsdns-23.co.uk."
},
{
"Value": "ns-1312.awsdns-36.org."
},
{
"Value": "ns-402.awsdns-50.com."
},
{
"Value": "ns-587.awsdns-09.net."
}
],
"Type": "NS",
"Name": "realguess.net.",
"TTL": 172800
},
{
"ResourceRecords": [
{
"Value": "ns-1727.awsdns-23.co.uk. awsdns-hostmaster.amazon.com. 1 7200 900 1209600 86400"
}
],
"Type": "SOA",
"Name": "realguess.net.",
"TTL": 900
},
{
"ResourceRecords": [
{
"Value": "192.168.153.123"
}
],
"Type": "A",
"Name": "www.realguess.net.",
"TTL": 86400
}
],
"MaxItems": "100"
}

Retrieve a single record set:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
$ aws route53 list-resource-record-sets --hosted-zone-id 1234567890ABC \
--start-record-name www.realguess.net --start-record-type A --max-items 1
{
"IsTruncated": false,
"ResourceRecordSets": [
{
"ResourceRecords": [
{
"Value": "192.168.153.123"
}
],
"Type": "A",
"Name": "www.realguess.net.",
"TTL": 86400
}
],
"MaxItems": "1"
}

In order to create a new record set, first create a JSON file to describe the new record:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
{
"Comment": "A new record set for the zone.",
"Changes": [
{
"Action": "CREATE",
"ResourceRecordSet": {
"Name": "api.realguess.net.",
"Type": "CNAME",
"TTL": 60,
"ResourceRecords": [
{
"Value": "www.realguess.net"
}
]
}
}
]
}

Add a new record set (note that the JSON file must use file:// starting path):

1
2
3
4
5
6
7
8
9
10
$ aws route53 change-resource-record-sets --hosted-zone-id 1234567890ABC \
--change-batch file:///path/to/record.json
{
"ChangeInfo": {
"Status": "PENDING",
"Comment": "A new record set for the zone.",
"SubmittedAt": "2013-12-06T00:00:00.000Z",
"Id": "/change/CHANGEID123"
}
}

The status of adding the new record is currently pending. Poll the server to get the updated status:

1
2
3
4
5
6
7
8
9
$ aws route53 get-change --id CHANGEID123
{
"ChangeInfo": {
"Status": "INSYNC",
"Comment": "A new record set for the zone.",
"SubmittedAt": "2013-12-06T00:00:00.000Z",
"Id": "/change/CHANGEID123"
}
}

A new record has been created and has been propagated to all hosts.