My task is to clear out our Route 53
from all the old Domain names. We have 700 records but only 200 running instances.
I have tried AWS CLI to get the EC2
instances IP address which worked fine.
I can’t seem to make a correct query on Route 53
CLI to get just the Domain Names plus the A records.
Ideally, I’d get both in a CSV format then use python to compare them.
Here is one of the Route 53
queries I tried:
aws route53 list-resource-record-sets --hosted-zone-id XXXX --output text --query 'ResourceRecordSets[*].[Name,ResourceRecords[*]]' | sed -E 's/s+/,/g' > domains.csv
2
Answers
I ended up using Vlookup with the two CSVs tables. I compared each IP Address in Sheet 1 with the IP address in Sheet 2. That worked for this use case as it was a one time operation.
As suggested by Mark B, use python and boto3.
This is by no means perfect and you should probably add some more filtering by type etc but it’s a start. I hope it helps you in the right direction.