Browse Source

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).
pull/1069/head
Karsten Sperling 7 years ago
parent
commit
ba311aacda
  1. 8
      dnsapi/dns_aws.sh

8
dnsapi/dns_aws.sh

@ -105,13 +105,9 @@ _get_root() {
return 1
fi
if _contains "$response" "<Name>$h.</Name>"; then
hostedzone="$(echo "$response" | sed 's/<HostedZone>/#&/g' | tr '#' '\n' | _egrep_o "<HostedZone><Id>[^<]*<.Id><Name>$h.<.Name>.*<PrivateZone>false<.PrivateZone>.*<.HostedZone>")"
hostedzone="$(echo "$response" | sed 's/<HostedZone>/#&/g' | tr '#' '\n' | _egrep_o "<HostedZone><Id>[^<]*<.Id><Name>$h.<.Name>.*<PrivateZone>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>.*<.Id>" | head -n 1 | _egrep_o ">.*<" | tr -d "<>")
if [ "$_domain_id" ]; then
_sub_domain=$(printf "%s" "$domain" | cut -d . -f 1-$p)

Loading…
Cancel
Save