By jacque006
Is there a way to get/add/modify DNS records in Digital Ocean via doctl or another command line utility? I was unable to find anything that looked relevant via doctl help.
It looks like worst case I could call the HTTP API directly, although I’m not sure how I would need to get the correct authentication credentials.
curl 'https://cloud.digitalocean.com/api/v1/domains/MY_DOMAIN/records/MY_RECORD' -X PUT
...
-H 'Cookie: ... _digitalocean2_session_v4=SOME_AUTH_TOKEN?; ...'
--data-raw '{"record":{"name":"_dnslink.www.MY_DOMAIN","record_type":"TXT","created_at":"2020-08-30T22:39:51.000Z","updated_at":"2020-09-24T03:55:21.000Z","port":null,"weight":null,"ttl":"300","data_record":"dnslink=/ipfs/IPFS_HASH","priority":null,"tag":null,"flags":null,"droplet_id":null,"floating_ip_id":null,"load_balancer_id":null}}'
My use case is I have a GitHub Action that uploads a web app to IPFS (https://ipfs.io/) that is served via a _dnslink.DOMAIN TXT record via CloudFlare (https://medium.com/pinata/how-to-easily-host-a-website-on-ipfs-9d842b5d6a01, section Setting Up Your DNS Records to Point to Cloudflare). After the upload happens, I need to update that _dnslink record to point to the new IPFS hash (_dnslink.DOMAIN TXT “dnslink=/ipfs/IPFS_HASH”)
Action yml (modified for clarity) in case it helps:
name: web
on:
push
jobs:
build-deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Install Node.js
uses: actions/setup-node@v1
with:
node-version: 12.x
- name: Install npm dependencies
run: npm install
- name: Typescript checks
run: npm run tsc
- name: Webpack build
run: npm run build
- name: Upload to Pinata (IPFS)
uses: aquiladev/ipfs-action@v0.1.4
with:
path: ./dist
service: pinata
pinataKey: ${{ secrets.PINATA_KEY }}
pinataSecret: ${{ secrets.PINATA_SECRET }}
- name: Install doctl
uses: digitalocean/action-doctl@v2
with:
token: ${{ secrets.DIGITAL_OCEAN_DOCKER_AUTH }}
- name: Update dnslink record
# HELP What should I do here?
run: doctl ...
This textbox defaults to using Markdown to format your answer.
You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!
Accepted Answer
Hi, hope you’re doing well. I did a little digging and found this documentation kinda buried on DO’s site:
https://www.digitalocean.com/docs/apis-clis/doctl/reference/compute/domain/records/
It does look like you can perform the necessary DNS actions via doctl but they are under the “compute” area of functionality.
Hope this helps and let us know if you have any other questions or feedback - good luck!
Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.
Full documentation for every DigitalOcean product.
The Wave has everything you need to know about building a business, from raising funding to marketing your product.
Stay up to date by signing up for DigitalOcean’s Infrastructure as a Newsletter.
New accounts only. By submitting your email you agree to our Privacy Policy
Scale up as you grow — whether you're running one virtual machine or ten thousand.
Sign up and get $200 in credit for your first 60 days with DigitalOcean.*
*This promotional offer applies to new accounts only.