Terraform provider
Manage your DNS as code
Our Terraform provider, zinn-digital/zinn, manages DNS records on the domains in your organisation and reads your sites, domains, plans and hosting regions as data sources. It is published on the Terraform Registry and built on the same public API as everything else.
Install
Declare the provider and run terraform init. Releases are signed, and Terraform verifies the signature when it downloads the provider.
terraform {
required_providers {
zinn = {
source = "zinn-digital/zinn"
}
}
}
# api_key falls back to ZINN_API_KEY.
provider "zinn" {}Quick start
Look up a domain by name and point www at it, then list the hosting regions.
data "zinn_regions" "all" {}
data "zinn_domains" "all" {}
resource "zinn_dns_record" "www" {
domain_id = one([for d in data.zinn_domains.all.domains : d.id if d.fqdn == "example.com"])
name = "www"
type = "CNAME"
value = "example.com."
ttl = 3600
}
output "regions" { value = [for r in data.zinn_regions.all.regions : r.slug] }Authentication
The provider reads a per-organisation API key from the api_key argument or from the ZINN_API_KEY environment variable. The regions and plans data sources need no key. Give the key only the permissions your configuration needs, for example viewing sites and managing DNS.
What it manages today
Resource: zinn_dns_record
Create, update, delete and import DNS records on your domains: A, AAAA, CNAME, MX, TXT, SRV and the other types your zone supports.
Data sources
zinn_sites and zinn_domains read your organisation. zinn_regions and zinn_plans read the public catalogue and need no key.
Generated from the specification
The provider's request and response models are generated from our OpenAPI specification, and new releases are published to the Terraform Registry automatically.
Read your inventory
Data sources need no resources at all, so you can start by reading what you already have.
# A read-only inventory of your organisation and the catalogue.
data "zinn_sites" "all" {}
data "zinn_plans" "agency" { product_line = "agency" }
output "site_count" { value = length(data.zinn_sites.all.sites) }
output "agency_plans" { value = [for p in data.zinn_plans.agency.plans : p.code] }Questions
Do you have a Terraform provider?
Yes. Use source = "zinn-digital/zinn" from the Terraform Registry. Today it manages DNS records and reads sites, domains, plans and hosting regions.
Can Terraform create sites or mailboxes?
Not yet. Sites, mailboxes and plans are managed in the dashboard, through the API, the SDKs or the Zinnector® CLI. The provider manages DNS records and reads the rest.
How do I bring an existing DNS record under Terraform?
Run terraform import with the domain id and the record id separated by a slash, for example terraform import zinn_dns_record.www <domain_id>/<record_id>.
Explore every endpoint
Anything the provider does not manage yet is available in the API, which is described endpoint by endpoint in the API reference.