Amazon Web Services (AWS) - List Route 53 DNS Records using the AWS CLI

by
Jeremy Canfield |
Updated: May 31 2023
| Amazon Web Services (AWS) articles
This assumes you have already configured the aws command line tool. If not, check out my article on Getting Started with the AWS CLI.
Route 53 is Amazon Web Services DNS. For example, Route 53 can be used to create an A record to associate a hostname such as www.example.com to a public IP address.
In Route 53, a Hosted Zone contains the DNS records.
The aws route53 list-hosted-zones command can be used to list the Hosted Zones that have been created.
~]$ aws route53 list-hosted-zones
{
"HostedZones": [
{
"Id": "/hostedzone/Z0561234JM1OE9ABCDH19",
"Name": "example.com.",
"CallerReference": "RISWorkflow-RD:98abdc50-5adf-1234-abdc-471041234a6c",
"Config": {
"Comment": "HostedZone created by Route53 Registrar",
"PrivateZone": false
},
"ResourceRecordSetCount": 3
}
]
}
Then the aws route53 list-resource-record-sets command can be used to list the DNS records in the Hosted Zone.
~]$ aws route53 list-resource-record-sets --hosted-zone-id Z0561234JM1OE9ABCDH19
{
"ResourceRecordSets": [
{
"Name": "example.com.",
"Type": "NS",
"TTL": 172800,
"ResourceRecords": [
{
"Value": "ns-550.awsdns-04.net."
},
{
"Value": "ns-499.awsdns-62.com."
},
{
"Value": "ns-1687.awsdns-18.co.uk."
},
{
"Value": "ns-1193.awsdns-21.org."
}
]
},
{
"Name": "example.com.",
"Type": "SOA",
"TTL": 900,
"ResourceRecords": [
{
"Value": "ns-550.awsdns-04.net. awsdns-hostmaster.amazon.com. 1 7200 900 1209600 86400"
}
]
},
{
"Name": "foo.example.com.",
"Type": "A",
"TTL": 300,
"ResourceRecords": [
{
"Value": "114.50.19.198"
}
]
}
]
}
And here is an example of how to limit the output using the --query option.
aws acm list-certificates --query 'ResourceRecordSets[?Name==`example.com.`]'
Did you find this article helpful?
If so, consider buying me a coffee over at