I’m working with Terraform to deploy my infrastructure on DigitalOcean, and I want to automate the creation of DNS records for each Droplet I set up.
Is there a way to have Terraform automatically add an A record for each Droplet’s IP address in my DigitalOcean domain zone? Ideally, I’d like the DNS records to be created or updated whenever I apply changes.
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!
These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.
Hey there! 👋
Setting up DNS records with Terraform on DigitalOcean is super straightforward and can save you a lot of time.
If you just want a basic setup, you can manage your domain and add an A record to point to your Droplet’s IP without needing any extra configurations.
Here’s an example:
This will create a domain (
example.com
) and set up an A record forwww.example.com
to point to your Droplet’s IP address. Once it’s applied, your DNS will be good to go!If you want the A record to automatically use your Droplet’s IP address, you can reference the Droplet’s IP in the
value
field.Just replace the IP with your Droplet’s
ipv4_address
like this:Here are a couple of resources to help you out:
Let me know if this helps!
If you’re new to Terraform, I would also suggest this Terraform ebook here.
- Bobby