Manage your links with Terraform

The RedirHub Terraform provider
RedirHub now has an official Terraform provider. Keep your redirects, website migrations, short links, QR codes and domains in Git, review every change as a plan in a pull request, and apply it from CI.
hclresource "redirhub_link" "old_domain" {
handler = "redirect"
url = "old-site.com"
destinations = ["https://new-site.com"]
type = "301"
forward_path = true
forward_query = true
}What you can manage#
- Every kind of link, one resource: redirhub_link covers domain redirects, website migration mappings, branded short links and QR codes, with the same fields as the API. Load a migration from a CSV in your repository with for_each.
- Domains and their DNS: redirhub_domain connects a domain and returns the DNS records it needs, ready for your DNS provider's Terraform resource. redirhub_domain_verification waits until the domain points to RedirHub, so new links go live on a domain that already answers.
- Links you already have: import any link by its id and any domain by its hostname. The redirhub_links data source lists ids by domain, kind or tag.
- Changes made in the dashboard show up: the next plan lists them, so nothing drifts away from what your files say.
Safe to run again#
A CI job that times out and runs again creates nothing twice. Every create carries an Idempotency-Key, and the API now honours it on every POST: the same key within 24 hours returns the first response instead of a second link. Your own scripts can send the header too.
Get started#
Create an API token under Settings → API tokens and follow Manage redirects as code with Terraform and CI, which includes a GitHub Actions workflow that posts the plan on each pull request. The provider is open source on GitHub. It works on Core, Pro and Enterprise.
