Skip to content

Instantly share code, notes, and snippets.

@amane-katagiri
Last active July 19, 2022 00:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save amane-katagiri/a567d26bab9d73d8f19933b66329bca7 to your computer and use it in GitHub Desktop.
Save amane-katagiri/a567d26bab9d73d8f19933b66329bca7 to your computer and use it in GitHub Desktop.
/etc/letsencrypt/scripts/dns-01-auth-netlify.sh
#!/bin/sh
API_TOKEN='YOUR_NETLIFY_API_TOKEN'
if [ "$CERTBOT_VALIDATION" != "" ] && [ "$CERTBOT_DOMAIN" != "" ]; then
DNS_ZONE_ID=$(curl -Ss \
-H 'Authorization: Bearer '"$API_TOKEN" \
'https://api.netlify.com/api/v1/dns_zones' \
| jq -r '(.[] | select(.name == "'"$CERTBOT_DOMAIN"'")).id')
curl -Ss -X POST \
-H 'Content-Type: application/json' \
-H "Authorization: Bearer $API_TOKEN" \
--data '{"type":"TXT","hostname": "_acme-challenge","value":"'"$CERTBOT_VALIDATION"'"}' \
"https://api.netlify.com/api/v1/dns_zones/${DNS_ZONE_ID}/dns_records"
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment