From ba311aacdaab1fad171a76065b1adca9b53f78a2 Mon Sep 17 00:00:00 2001 From: Karsten Sperling Date: Wed, 11 Oct 2017 13:19:36 +1300 Subject: [PATCH] Skip private hosted zones correctly This fixes the cases where a private zone is a sub-domain of a public zone, e.g. foo.com (public) and vpc.foo.com (private). --- dnsapi/dns_aws.sh | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/dnsapi/dns_aws.sh b/dnsapi/dns_aws.sh index 40782573..27dd5ba0 100755 --- a/dnsapi/dns_aws.sh +++ b/dnsapi/dns_aws.sh @@ -105,13 +105,9 @@ _get_root() { return 1 fi - if _contains "$response" "$h."; then - hostedzone="$(echo "$response" | sed 's//#&/g' | tr '#' '\n' | _egrep_o "[^<]*<.Id>$h.<.Name>.*false<.PrivateZone>.*<.HostedZone>")" + hostedzone="$(echo "$response" | sed 's//#&/g' | tr '#' '\n' | _egrep_o "[^<]*<.Id>$h.<.Name>.*false<.PrivateZone>.*<.HostedZone>")" + if [ -n "$hostedzone" ]; then _debug hostedzone "$hostedzone" - if [ -z "$hostedzone" ]; then - _err "Error, can not get hostedzone." - return 1 - fi _domain_id=$(printf "%s\n" "$hostedzone" | _egrep_o ".*<.Id>" | head -n 1 | _egrep_o ">.*<" | tr -d "<>") if [ "$_domain_id" ]; then _sub_domain=$(printf "%s" "$domain" | cut -d . -f 1-$p)