Terraform Provider

Manage your DNS zones as code with the hiddenprimary.ch Terraform provider.

Installation

The provider is published in the Terraform Registry. Declare it and run terraform init — there is nothing to build and nothing to place by hand.

main.tf
terraform {
  required_providers {
    hiddenprimary = {
      source  = "hiddenprimary/hiddenprimary"
      version = "~> 1.0"
    }
  }
}

Releases are signed; terraform init verifies the signature and records the checksums in your lock file. Source and issue tracker: github.com/hiddenprimary/terraform-provider-hiddenprimary.

Provider Configuration

Create an API key in the portal under Account → API keys. Zone operations need the zones:read and zones:write scopes; the plans data source also needs billing:read.

main.tf
provider "hiddenprimary" {
  api_key = var.hiddenprimary_api_key
}

Or leave the block out entirely and use the environment. Prefer this, or a variable marked sensitive — a key written into a .tf file ends up in version control.

terminal
$ export HIDDENPRIMARY_API_KEY="hp_sk_..."
ArgumentTypeRequiredDescription
api_keystringyesAPI key, sensitive. May come from HIDDENPRIMARY_API_KEY instead of the configuration.
api_urlstringnoDefaults to https://hiddenprimary.ch/v1. May also be set with HIDDENPRIMARY_API_URL.

Resources

hiddenprimary_zone

Manages a DNS zone.

main.tf
resource "hiddenprimary_zone" "main" {
  name       = "example.ch"
  primary_ips = ["192.0.2.1", "192.0.2.2"]
}

Leave primary_ips out for a zone whose content you upload, or whose nameserver sits on an address that changes and identifies itself by an authenticated NOTIFY instead.

ArgumentTypeRequiredDescription
namestringyesDomain name (e.g. example.ch). Changing it replaces the zone.
primary_ipslist(string)noAddresses of your own nameserver, which we transfer the zone from.
AttributeTypeDescription
idstringNumeric zone ID.
statusstringZone status (active, pending, error).
serialnumberSOA serial of the copy currently served.
transfer_methodstringThe stored transfer method: axfr or ixfr. Every new zone is created as axfr, and uploading a zone file does not change it. The value does not pick the wire protocol: whether a refresh runs as a full or incremental transfer is negotiated per RFC 1995 and cannot be pinned per zone.

Data Sources

hiddenprimary_zone

Look up an existing zone by name.

main.tf
data "hiddenprimary_zone" "existing" {
  name = "example.ch"
}
 
output "zone_status" {
  value = data.hiddenprimary_zone.existing.status
}

hiddenprimary_plans

List the available plans. Needs the billing:read scope.

main.tf
data "hiddenprimary_plans" "all" {}
 
output "plans" {
  value = data.hiddenprimary_plans.all.plans
}

price_monthly is in cents.

Import Existing Zones

terminal
$ terraform import hiddenprimary_zone.main 42

The ID is the numeric zone ID from the portal or the API.