Skip to content

Managing Zones as Code

You can keep zones in version control and apply them to Poweradmin from a pipeline. Changes made this way go through the same permission checks, zone ownership and change log as edits in the web UI. There are two ways to do it:

  • the Terraform provider, for teams that already use Terraform or OpenTofu
  • API v2 called from your own scripts

Terraform and OpenTofu

terraform-provider-poweradmin manages zones, records, RRsets, zone metadata, DNSSEC keys, users, groups and zone templates as resources. terraform plan shows what would change before terraform apply makes the change.

terraform {
  required_providers {
    poweradmin = {
      source = "poweradmin/poweradmin"
    }
  }
}

provider "poweradmin" {
  api_url = "https://dns.example.com"
  api_key = var.poweradmin_api_key
}

resource "poweradmin_zone" "example" {
  name = "example.com"
  type = "MASTER"
}

resource "poweradmin_rrset" "www" {
  zone_id = poweradmin_zone.example.id
  name    = "www"
  type    = "A"
  ttl     = 300

  records = [
    { content = "192.0.2.10" },
    { content = "192.0.2.11" },
  ]
}

Check the provider's compatibility table for the release that matches your Poweradmin version.

Scripts with API v2

Create an API key for the pipeline. Give it access only to the zones it manages.

Replace a whole RRset. A request to /api/v2/zones/{id}/rrsets sets every record for one name and type. Records you leave out are removed, and other names and types are not touched.

curl -X PUT "https://dns.example.com/api/v2/zones/42/rrsets" \
  -H "X-API-Key: $POWERADMIN_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"name": "www", "type": "A", "ttl": 300,
       "records": [{"content": "192.0.2.10"}, {"content": "192.0.2.11"}]}'

Preview, then apply. POST /api/v2/zones/{id}/records/bulk takes a list of create, update and delete operations. With "dry_run": true it runs every check and reports what would happen without writing anything. Send the same body without dry_run to apply it. The comment is stored in the change log.

curl -X POST "https://dns.example.com/api/v2/zones/42/records/bulk" \
  -H "X-API-Key: $POWERADMIN_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"dry_run": true, "comment": "deploy 2026-12-05",
       "operations": [
         {"action": "create", "name": "api", "type": "A", "content": "192.0.2.20", "ttl": 300},
         {"action": "delete", "id": 123}
       ]}'

See Endpoints for the full list.

Tools that talk to PowerDNS directly

Some tools, such as DNSControl and octoDNS, have a provider that writes straight to the PowerDNS HTTP API. That works, but it goes around Poweradmin:

  • Poweradmin's permissions and zone ownership are not checked
  • the change log does not record the change or who made it
  • zones created that way have no owner in Poweradmin until an administrator assigns one

If more than one person or team edits the same zones, use the Terraform provider or API v2 instead, so every change is checked and logged in one place.