Skip to content

Dynamically update Cloudflare DNS A and AAAA records without giving your hosts control to your whole DNS settings through a Cloudflare Worker.

License

Notifications You must be signed in to change notification settings

moverest/cf-dns-update-worker

Repository files navigation

cf-dns-update-worker

This project is a Cloudflare worker that enables to update dynamically A and AAAA records with the Cloudflare DNS service.

⚠️ This project is still in its early stage of development. The worker's API is still not stable nor documented. Testing should also be improved.

Installation & Deployment

To deploy a new installation on your Cloudflare instance, you can use wrangler.

First login to your Cloudflare account:

wrangler login

Copy the wrangler.yaml.example to wrangler.yaml and fill the values. You will need to create new Workers KV Namespace in the Cloudflare dashboard.

Create a Cloudflare token within the dashboard with the needed DNS permissions and set the secrets with wrangler:

wrangler secret put CF_DNS_TOKEN --env production
wrangler secret put CF_ZONE_ID --env production

Next, deploy the worker:

wrangler publish --env production

You will then need to generate a salt to generate API keys and their respective token IDs.

curl -s 'https://your.domain.to.your.worker/salt'

Take the salt value and push it to the secrets with wrangler:

wrangler secret put TOKEN_SALT --env production

Then create a admin token with the token_id value by replacing <token_id> with its value:

wrangler kv:key put -binding KV --env production token:<token_id> '{"type": "ADMIN"}'

You can then use the apikey value to connect to the API. To check its validity run:

curl -s 'https://your.domain.to.your.worker/tokens/me' \
     -H 'Content-Type: application/json' \
     -H 'Authorization: Bearer '$MY_API_KEY

About

Dynamically update Cloudflare DNS A and AAAA records without giving your hosts control to your whole DNS settings through a Cloudflare Worker.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published