whereisaaron / dehydrated-route53-hook-script

Dehydrated hook script that employs cli53 to enable dns-01 challenges with AWS Route 53
MIT License
29 stars 20 forks source link

Doesnt work with private zones #5

Open patrickdk77 opened 4 years ago

patrickdk77 commented 4 years ago

simple modifications to work with private zones.

local ZONELIST=$(cli53 list -format json | jq --raw-output '.[] | select(.Config.PrivateZone == false) | .Name, .Id' | sed -e 's/.$//' | xargs echo -n | sed -e 's/ \/hostedzone\//|/g')

local TESTDOMAIN="${DOMAIN}" local DOM="" local ID=""

while [[ -n "$TESTDOMAIN" ]]; do for zone in $ZONELIST; do ID="${zone##|}" DOM="${zone%|}" if [[ "$DOM" == "$TESTDOMAIN" ]]; then echo "$ID" return 0 fi done TESTDOMAIN=$(get_base_name "$TESTDOMAIN") done

svenedge commented 1 year ago

I think the text formatting ate some important punctuation. This is what worked for me:

function find_zone() {
  local DOMAIN="${1}"

  local ZONELIST=$(cli53 list -format json | jq --raw-output '.[] | select(.Config.PrivateZone == false) | .Name, .Id' | sed -e 's/\.$//' | xargs echo -n | sed -e 's# /hostedzone/#|#g')

  local TESTDOMAIN="${DOMAIN}"
  local DOM=""
  local ID=""

  while [[ -n "$TESTDOMAIN" ]]; do
    for zone in $ZONELIST; do
      ID="${zone##*|}"
      DOM="${zone%|*}"
      if [[ "$DOM" == "$TESTDOMAIN" ]]; then
        echo "$ID"
        return 0
      fi
    done
    TESTDOMAIN=$(get_base_name "$TESTDOMAIN")
  done

  return 1
}

I also had to add export PATH="$PATH:/usr/local/bin" as that's where cli53 is.

patrickdk77 commented 1 year ago

Looks to have ate the *'s

Quoting Sven Edge @.***>:

I think the text formatting ate some important punctuation. This is
what worked for me:

function find_zone() {
  local DOMAIN="${1}"

  local ZONELIST=$(cli53 list -format json | jq --raw-output '.[] |  
select(.Config.PrivateZone == false) | .Name, .Id' | sed -e  
's/\.$//' | xargs echo -n | sed -e 's# /hostedzone/#|#g')

  local TESTDOMAIN="${DOMAIN}"
  local DOM=""
  local ID=""

  while [[ -n "$TESTDOMAIN" ]]; do
    for zone in $ZONELIST; do
      ID="${zone##*|}"
      DOM="${zone%|*}"
      if [[ "$DOM" == "$TESTDOMAIN" ]]; then
        echo "$ID"
        return 0
      fi
    done
    TESTDOMAIN=$(get_base_name "$TESTDOMAIN")
  done

  return 1
}

I also had to add export PATH="$PATH:/usr/local/bin" as that's
where cli53 is.

-- Reply to this email directly or view it on GitHub: https://github.com/whereisaaron/dehydrated-route53-hook-script/issues/5#issuecomment-1693414096 You are receiving this because you authored the thread.

Message ID:
@.***>