Skip to content
0850 554 5439 [email protected]

Blog

Tutorials, guides, product news and engineering insights from the team that runs your hosting.

Technology

Managing DNS with Terraform and the API

10 November 2026 2 min read
Share this post

Editing records one by one in a panel works for small projects. When you run more servers or build infrastructure as code, managing DNS with Terraform and the API reduces mistakes and makes changes traceable. Gyro DNS comes with an API, the gyro CLI and a Terraform provider.

Managing DNS with Terraform and the API

Before you start

  • You need a Gyro DNS service; API, CLI and Terraform are included in the Free plan too. The examples use service id 789.
  • Create an API key (starts with wck_) in the client area, and store it with gyro configure for the CLI.

Terraform

The provider is published on the Terraform Registry as gyro-hosting/gyro. Pass your key in GYRO_TOKEN:

terraform {
  required_providers {
    gyro = {
      source = "gyro-hosting/gyro"
    }
  }
}

provider "gyro" {}   # reads the API key from GYRO_TOKEN
resource "gyro_dns_zone" "example" {
  service_id = 789          # your Gyro DNS service id
  name       = "example.com"
  dnssec     = true
}

resource "gyro_dns_record" "www" {
  service_id = gyro_dns_zone.example.service_id
  zone       = gyro_dns_zone.example.name
  name       = "www"
  type       = "A"
  ttl        = 300
  records    = ["203.0.113.10"]
}

resource "gyro_dns_record" "mx" {
  service_id = gyro_dns_zone.example.service_id
  zone       = gyro_dns_zone.example.name
  name       = "@"
  type       = "MX"
  records    = ["10 mx1.example.com."]
}

output "nameservers" { value = gyro_dns_zone.example.nameservers }
output "ds_records"  { value = gyro_dns_zone.example.ds_records }
  • A zone goes live after ownership is verified. While status is pending, delegate to the nameservers or create the verification_txt_name / verification_txt_value TXT record at your current DNS.
  • gyro_dns_record manages all values of one name and type. Names without a trailing dot are relative to the zone.
  • With dnssec = true, enter ds_records at your registrar; remove them there before disabling.
  • Import: terraform import gyro_dns_zone.example 789/example.com and terraform import gyro_dns_record.www 789/example.com/www/A.

gyro CLI

gyro dns zone create 789 --name example.com
gyro dns zone list 789
gyro dns rrset set 789 example.com --name www --type A --ttl 300 --records 203.0.113.10
gyro dns rrset list 789 example.com
gyro dns dnssec enable 789 example.com
gyro dns zone export 789 example.com

Destructive commands ask for confirmation; use --yes in scripts and --dry-run to preview the request.

REST API

DNS endpoints live under /api/v1/client/cloud/dns/{id}/…:

curl -X PUT \
  https://www.gyrohosting.com/api/v1/client/cloud/dns/789/zones/example.com/records \
  -H "Authorization: Bearer $GYRO_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"name":"www","type":"A","ttl":300,"records":["203.0.113.10"]}'

Deleting, disabling DNSSEC and importing require "confirm": true. The default limit is 60 requests per minute per key. Full reference in the developer docs.

Comments0

No Comments Yet

Be the first to share your thoughts.

Join the Discussion

Please sign in or sign up to leave a comment.

Never Miss a Post

Get our latest tutorials, guides and product news in your inbox.

You're subscribed to our newsletter.