Skip to content

Commit 36c84b7

Browse files
author
Andrew Lorien
committed
https://github.com/bash-my-aws/bash-my-aws/pull/252
1 parent a0293a3 commit 36c84b7

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed

lib/route53-functions

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,35 @@ hosted-zone-ns-records(){
6565
done
6666
}
6767

68+
hosted-zone-records(){
69+
70+
# List Records in a Route53 Hosted Zone
71+
# NOTE: AWS alias records are shown with a fake TTL of 86400.
72+
#
73+
# $ hosted-zones bash-my-aws.org
74+
# /hostedzone/ZJ6ZCG2UD6OKX 5 NotPrivateZone bash-my-aws.org.
75+
#
76+
# $ hosted-zones bash-my-aws.org | hosted-zone-records
77+
# bash-my-aws.org. 900 SOA ns-1549.awsdns-01.co.uk. awsdns-hostmaster.amazon.com. 1 7200 900 1209600 86400
78+
# bash-my-aws.org. 300 NS ns-1464.awsdns-55.org.
79+
# bash-my-aws.org. 300 A 185.199.108.153
80+
# bash-my-aws.org. 300 A 185.199.109.153
81+
# bash-my-aws.org. 300 TXT "google-site-verification=RbKejqu95y4Q78BkWnjaiM0rl6SYugtTdVLexK35b2k"
82+
# lb.bash-my-aws.org. 86400 ALIAS dualstack.lb-bmaorg-12345.us-east-1.elb.amazonaws.com
83+
84+
local hosted_zone_id="$(__bma_read_inputs $@)"
85+
[[ -z "$hosted_zone_id" ]] && __bma_usage "hosted-zone-id" && return 1
86+
87+
aws route53 list-resource-record-sets \
88+
--hosted-zone-id "$hosted_zone_id" \
89+
--output json |
90+
jq --raw-output '.ResourceRecordSets[] |
91+
(select(.ResourceRecords) |
92+
"\(.Name) \t\(.TTL) \t\(.Type) \t\(.ResourceRecords[].Value)\n"),
93+
(select(.AliasTarget) |
94+
"\(.Name) \t86400 \tALIAS \t\(.AliasTarget.DNSName)\n")'
95+
}
96+
6897
hosted-zone-a-records(){
6998

7099
# Generate NS records for delegating domain to AWS

0 commit comments

Comments
 (0)