Skip to search Skip to main content
Posted by
James McCarthy on
June 9, 2020
Technical

Using Terraform to automate DNS Management

Introduction

In this blog we are going to look at the reasons why more of our customers are using Terraform to manage their DNS resources, provide an overview of how Terraform works, and then let you know how to get started.

Why this approach?

The traditional approach to DNS management has been to use a DNS provider’s GUI with possibly some use of the API to automate certain tasks. The operational overhead and security considerations of this often meant that control of this provider resides with a central team who become a bottleneck for change (at no fault of their own, of course!).

Terraform is HashiCorp’s infrastructure as code product. It allows an organization to define infrastructure assets with providers as text in a configuration file. This moves away from manual, error-prone changes to automation with all the benefits that that brings.

Organisations who build a deployment pipeline using tools such as Terraform are able to decentralize control of providers such as NS1 and allow a wider set of teams to make changes. Having a consistent approach to change management across multiple providers is also ideal. It also makes rolling back to previous states easy to do.

White Paper

Leveraging Integrations to Increase the Velocity of Application and Infrastructure Delivery

Learn how automations and integrations can improve your workflow when you leverage Ansible, Terraform, and Kubernetes.

Private DNS Delays in Devops

How does Terraform work?

It is important to understand how Terraform works before adopting this approach. Terraform is declarative: we declare what the desired state of the infrastructure we are managing is by configuring individual resources. Terraform then uses the provider’s API to achieve that state. Note that here we are using the Terraform definition of resources and not a shortening of the DNS resource record -- although we will be defining our resource records as Terraform resources in our configuration files!

To do this, Terraform keeps a local state of the resources you have defined in your configuration. Before making a change it will refresh this state before informing you of what will be changed if you do choose to apply this change. You can then confirm you are happy with these changes and Terraform will use NS1’s API to make those changes on our platform. These changes will then rapidly propagate across our network.

How do I get started?

To see an example of using Terraform to create a simple DNS zone you can view this Help Center article. We will also be adding further documentation for Terraform which will help you move beyond simple examples.

Request a Demo

Contact Us

Get Pricing

Learn More About our Partner Program