From 7c2ba308cd5c07d6e2f5b16cc3d8108b9567ac96 Mon Sep 17 00:00:00 2001 From: Jeremy Blosser Date: Thu, 2 Jan 2020 18:58:53 -0600 Subject: [PATCH 1/2] add hosted-zone-records to list full route53 record sets from a zone --- lib/route53-functions | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/lib/route53-functions b/lib/route53-functions index 51730f6c..7d0c5212 100644 --- a/lib/route53-functions +++ b/lib/route53-functions @@ -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")' +} From 0dc79209a73385fa9759e8b69ba349d95da7195d Mon Sep 17 00:00:00 2001 From: Jeremy Blosser Date: Thu, 2 Jan 2020 18:59:16 -0600 Subject: [PATCH 2/2] update build post hosted-zone-records --- aliases | 1 + docs/command-reference.md | 17 +++++++++++++++++ functions | 1 + 3 files changed, 19 insertions(+) diff --git a/aliases b/aliases index 77d04b54..2f2caa72 100644 --- a/aliases +++ b/aliases @@ -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' diff --git a/docs/command-reference.md b/docs/command-reference.md index c8c490e5..ea448e4d 100644 --- a/docs/command-reference.md +++ b/docs/command-reference.md @@ -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 diff --git a/functions b/functions index 24edbdc7..143880d0 100644 --- a/functions +++ b/functions @@ -52,6 +52,7 @@ elb-instances elb-stack elbs hosted-zone-ns-records +hosted-zone-records hosted-zones iam-role-principal iam-roles