Skip to content

germanbrew/terraform-provider-hetznerdns

Repository files navigation

Terraform Provider for Hetzner DNS

Terraform OpenTofu GitHub Release GitHub Actions Workflow Status

You can find resources and data sources documentation there or here.

This project has been forked from timohirt/terraform-provider-hetznerdns, which is no longer maintained.

Requirements

Installing and Using this Plugin

You most likely want to download the provider from Terraform Registry. The provider is also published in the OpenTofu Registry.

Migration Guide

If you previously used the timohirt/hetznerdns provider, you can easily replace the provider in your terraform state by following our migration guide in the provider documentation.

Using Provider from Terraform Registry (TF >= 1.0)

This provider is published and available there. If you want to use it, just add the following to your terraform.tf:

terraform {
  required_providers {
    hetznerdns = {
      source = "germanbrew/hetznerdns"
      version = "3.0.0"  # Replace with latest version
    }
  }
  required_version = ">= 1.0"
}

Then run terraform init to download the provider.

Authentication

Once installed, you have three options to provide the required API token that is used to authenticate at the Hetzner DNS API.

Enter API Token when needed

You can enter it every time you run terraform.

Configure the Provider to take the API Token from a Variable

Add the following to your terraform.tf:

variable "hetznerdns_token" {}

provider "hetznerdns" {
  api_token = var.hetznerdns_token
}

Now, assign your API token to hetznerdns_token in terraform.tfvars:

hetznerdns_token = "kkd993i3kkmm4m4m4"

You don't have to enter the API token anymore.

Inject the API Token via the Environment

Assign the API token to HETZNER_DNS_TOKEN env variable.

export HETZNER_DNS_TOKEN=<your api token>

The provider uses this token, and you don't have to enter it anymore.

Development

Requirements

Install and update development tools

Run the following command

make install-devtools

Makefile Commands

Check the subcommands in our Makefile for useful dev tools and scripts.

Testing the provider locally

To test the provider locally:

  1. Build the provider binary with make build

  2. Create a new file ~/.terraform.rc and point the provider to the absolute directory path of the binary file:

    provider_installation {
        dev_overrides {
            "germanbrew/hetznerdns" = "/path/to/your/terraform-provider-hetznerdns/bin/"
        }
        direct {}
    }
    • Set the variable before running terraform commands:
    TF_CLI_CONFIG_FILE=~/.terraform.rc terraform plan
    • Or set the env variable TF_CLI_CONFIG_FILE and point it to ~/.terraform.rc: e.g.
    export TF_CLI_CONFIG_FILE=~/.terraform.rc`
  3. Now you can just use terraform normally. A warning will appear, that notifies you that you are using an provider override

    Warning: Provider development overrides are in effect
    ...
    
  4. Unset the env variable if you don't want to use the local provider anymore:

    unset TF_CLI_CONFIG_FILE