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).
This commit is contained in:
Karsten Sperling 2017-10-11 13:19:36 +13:00
parent b6c2fc5a69
commit ba311aacda

View File

@ -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>")"
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)