Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions aliases
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ alias elb-instances='~/.bash-my-aws/bin/bma elb-instances'
alias elb-stack='~/.bash-my-aws/bin/bma elb-stack'
alias elbs='~/.bash-my-aws/bin/bma elbs'
alias hosted-zone-ns-records='~/.bash-my-aws/bin/bma hosted-zone-ns-records'
alias hosted-zone-records='~/.bash-my-aws/bin/bma hosted-zone-records'
alias hosted-zones='~/.bash-my-aws/bin/bma hosted-zones'
alias iam-role-principal='~/.bash-my-aws/bin/bma iam-role-principal'
alias iam-roles='~/.bash-my-aws/bin/bma iam-roles'
Expand Down
17 changes: 17 additions & 0 deletions docs/command-reference.md
Original file line number Diff line number Diff line change
Expand Up @@ -1206,6 +1206,23 @@ Generate NS records for delegating domain to AWS
bash-my-aws.org. 300 IN NS ns-1464.awsdns-55.org.


### hosted-zone-records

List Records in a Route53 Hosted Zone
NOTE: AWS alias records are shown with a fake TTL of 86400.

$ hosted-zones bash-my-aws.org
/hostedzone/ZJ6ZCG2UD6OKX 5 NotPrivateZone bash-my-aws.org.

$ hosted-zones bash-my-aws.org | hosted-zone-records
bash-my-aws.org. 900 SOA ns-1549.awsdns-01.co.uk. awsdns-hostmaster.amazon.com. 1 7200 900 1209600 86400
bash-my-aws.org. 300 NS ns-1464.awsdns-55.org.
bash-my-aws.org. 300 A 185.199.108.153
bash-my-aws.org. 300 A 185.199.109.153
bash-my-aws.org. 300 TXT "google-site-verification=RbKejqu95y4Q78BkWnjaiM0rl6SYugtTdVLexK35b2k"
lb.bash-my-aws.org. 86400 ALIAS dualstack.lb-bmaorg-12345.us-east-1.elb.amazonaws.com


## s3-commands


Expand Down
1 change: 1 addition & 0 deletions functions
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ elb-instances
elb-stack
elbs
hosted-zone-ns-records
hosted-zone-records
hosted-zones
iam-role-principal
iam-roles
Expand Down
29 changes: 29 additions & 0 deletions lib/route53-functions
Original file line number Diff line number Diff line change
Expand Up @@ -60,3 +60,32 @@ hosted-zone-ns-records(){
]" \
--output text
}

hosted-zone-records(){

# List Records in a Route53 Hosted Zone
# NOTE: AWS alias records are shown with a fake TTL of 86400.
#
# $ hosted-zones bash-my-aws.org
# /hostedzone/ZJ6ZCG2UD6OKX 5 NotPrivateZone bash-my-aws.org.
#
# $ hosted-zones bash-my-aws.org | hosted-zone-records
# bash-my-aws.org. 900 SOA ns-1549.awsdns-01.co.uk. awsdns-hostmaster.amazon.com. 1 7200 900 1209600 86400
# bash-my-aws.org. 300 NS ns-1464.awsdns-55.org.
# bash-my-aws.org. 300 A 185.199.108.153
# bash-my-aws.org. 300 A 185.199.109.153
# bash-my-aws.org. 300 TXT "google-site-verification=RbKejqu95y4Q78BkWnjaiM0rl6SYugtTdVLexK35b2k"
# lb.bash-my-aws.org. 86400 ALIAS dualstack.lb-bmaorg-12345.us-east-1.elb.amazonaws.com

local hosted_zone_id="$(__bma_read_inputs $@)"
[[ -z "$hosted_zone_id" ]] && __bma_usage "hosted-zone-id" && return 1

aws route53 list-resource-record-sets \
--hosted-zone-id "$hosted_zone_id" \
--output json |
jq --raw-output '.ResourceRecordSets[] |
(select(.ResourceRecords) |
"\(.Name) \t\(.TTL) \t\(.Type) \t\(.ResourceRecords[].Value)\n"),
(select(.AliasTarget) |
"\(.Name) \t86400 \tALIAS \t\(.AliasTarget.DNSName)\n")'
}