Free Trial
Features

Register and Manage Domains with Terraform

Wilson Lin's profile picture Wilson Lin on

DNSimple's Terraform provider makes it easy to manage your DNS infrastructure and set up any DNS records you need. But there wasn't a way to leverage Terraform to manage your domains, so we made some improvements.

Today, we're excited to announce you can use our latest Terraform provider release to manage your domain registration with the dnsimple_registered_domain resource. Leverage the advantages of infrastructure as code to manage one of your most important company assets: your domain names.

Among other things, you can now use Terraform to automate the following operations on a registered domain in DNSimple:

  • Change name servers (domain delegation)
  • Enable/Disable WHOIS privacy
  • Enable/Disable domain auto-renewal
  • Enable/Disable DNSSEC.

Important note: your domains are never at risk if you use Terraform to manage them. When a domain registration resource is deleted in Terraform, we never delete the domain or registration at DNSimple. It just removes the ability to manage the domain registration through Terraform by removing the reference to the domain from the Terraform state. You can register your domains through Terraform without worrying about accidentally deleting the registration.

Set up and manage everything domain-related in Terraform — registration, SSL certificates, records, email forwarding, delegation, and more. With one terraform apply, your critical domain infrastructure, from registration to MX records and SSL private keys, is safely tracked and managed. Terraform has a full list of resources you can connect with DNSimple.

How to register domains in Terraform

You can start registering domains in Terraform right now:

  1. Sign up for a DNSimple account if you haven't already.

  2. Have an access token ready. This guide has the steps to create one. You'll also need your account ID, located in the Automation tab in your account settings.

  3. Set up the DNSimple provider in your Terraform .tf file:

  terraform {
    required_providers {
      dnsimple = {
        source = "dnsimple/dnsimple"
        version = "1.1.0"
      }
    }
  }

  provider "dnsimple" {
    token    = var.dnsimple_token
    account  = var.dnsimple_account
  }
  1. Define your domain resources. To register a domain, you'll need a contact, which you can define in Terraform:
  resource "dnsimple_registered_domain" "coolco" {
    name                  = "cool.co"
    contact_id            = dnsimple_contact.me
    auto_renew_enabled    = true
    whois_privacy_enabled = true
    dnssec_enabled        = false
  }

  resource "dnsimple_contact" "me" {
    first_name     = "John"
    last_name      = "Appleseed"
    address1       = "2 Main St"
    city           = "San Francisco"
    state_province = "CA"
    postal_code    = "90210"
    country        = "US"
    phone          = "+1401239523"
    email          = "john@appleseed.me"
  }
  1. Run terraform apply to register your domain.

Internally, the registration leverages the recent updates in the domain management APIs to ensure we support both real-time and non real-time registrations. This opens up the possibility of registering domains in a variety of TLDs, including country-code TLDs (ccTLDs), that can be more complex to work with.

How to manage your existing domains in Terraform

If you already have a registered domain with DNSimple, and you wish to manage it using Terraform, you can import it into your Terraform state by declaring the resources as previously mentioned and then running terraform import. For example, given the previous "cool.co" domain and "coolco" resource:

terraform import dnsimple_registered_domain.coolco cool.co

And that's it! Add Terraform resources to set up your SSL certificates, DNS records, and more. You can also enable auto-renew, WHOIS privacy, and DNSSEC just by setting their attribute to true — that means no more multi-step checkouts or forms in browsers. The resource has also been designed to ensure if you delete the dnsimple_registered_domain resource, it will not affect your domains or their configuration in any way — it just removes the ability to manage the domain registration through Terraform.

Our provider documentation has even more examples of registering, managing, and importing domains. You can also check out our support article or provider docs for more details on using Terraform with DNSimple.

Simple, secure domain management

Our domain registration service now supports over 500 TLDs. When combined with the simplicity of Terraform, they're even easier to register.

You'll find more details about our Terraform integration and how to configure it in our support documentation. Or read more about automating your DNS provisioning with DNSimple and HashiCorp. Have more questions or want to talk more about your domain management needs? Get in touch — we'd love to chat.

If you're not already using DNSimple, give us a try free for 30 days and see how simple domain management can be with all our dev-friendly tools, including our API, SDKs, and Terraform provider.

Share on Twitter and Facebook

Wilson Lin's profile picture

Wilson Lin

Backender, frontender, man in the middle.

We think domain management should be easy.
That's why we continue building DNSimple.

Try us free for 30 days
4.5 stars

4.3 out of 5 stars.

Based on Trustpilot.com and G2.com reviews.