The official redirect.pizza Terraform provider lets you manage redirects as infrastructure as code: define them in configuration files, review changes in pull requests and apply them through your existing Terraform workflow. It exposes a single resource, redirectpizza_redirect.
The provider is published on the Terraform Registry: registry.terraform.io/providers/enflow/redirectpizza. The registry documentation lists every argument and attribute.
Authentication
The provider authenticates with an API token. Create one under More, API/MCP with the redirects:read and redirects:write scopes, and pass it to the provider through a variable rather than hardcoding it.
Example
terraform {
required_providers {
redirectpizza = {
source = "enflow/redirectpizza"
}
}
}
# Set the value in a *.tfvars file or with -var="rp_token=..."
variable "rp_token" {}
provider "redirectpizza" {
token = var.rp_token
}
resource "redirectpizza_redirect" "old-domain" {
sources = [
"old-domain.com",
"www.old-domain.com",
]
destination {
url = "https://new-domain.com"
}
# Optional. One of: permanent, temporary, permanent:308, temporary:307, frame
redirect_type = "permanent"
# Optional
tracking = true
uri_forwarding = true
keep_query_string = false
tags = ["prod", "marketing"]
}Run terraform apply and the redirect is created in your account. Terraform creates the redirect, but the DNS of new hostnames still has to point at redirect.pizza. Make that change at your DNS provider, or let automatic DNS do it.