Skip to content

Repository files navigation

redirect.pizza Terraform Provider

Terraform provider for redirect.pizza. Use the redirectpizza_redirect resource to manage redirects as code.

Use this provider together with your DNS provider. You may hardcode values from the DNS records documentation, or your own Dedicated IP.

Using the provider

terraform {
  required_providers {
    redirectpizza = {
      source  = "enflow/redirectpizza"
      version = "~> 0.2"
    }
  }
}

# Set the variable value in a *.tfvars file or with -var="rp_token=..."
variable "rp_token" {
  type      = string
  sensitive = true
}

provider "redirectpizza" {
  token = var.rp_token
}

resource "redirectpizza_redirect" "old-domain" {
  sources = [
    "old-domain.com",
  ]

  destination {
    url = "https://new-domain.com"
  }

  # Optional. One of: permanent, temporary, permanent:308, temporary:307, frame
  redirect_type = "permanent"

  tracking          = true
  uri_forwarding    = true
  keep_query_string = false
  tags              = ["prod", "dev"]
}

Requirements

Import

The import ID is the numeric redirect ID from the API or from the dashboard URL (for example https://redirect.pizza/redirects/123123123).

Terraform 1.5+ import block:

import {
  to = redirectpizza_redirect.old-domain
  id = "123123123"
}

CLI:

terraform import redirectpizza_redirect.old-domain 123123123

Building The Provider

  1. Clone the repository
  2. Enter the repository directory
  3. Build the provider using the Go install command:
$ go install

Adding Dependencies

This provider uses Go modules. Please see the Go documentation for the most up to date information about using Go modules.

To add a new dependency github.com/author/dependency to this Terraform provider:

go get github.com/author/dependency
go mod tidy

Then commit the changes to go.mod and go.sum.

Developing the Provider

If you wish to work on the provider, you'll first need Go installed on your machine (see Requirements above).

To compile the provider, run go install. This will build the provider and put the provider binary in the $GOPATH/bin directory.

To generate or update documentation, run go generate.

To run locally, add a development override for enflow/redirectpizza (or registry.terraform.io/enflow/redirectpizza) pointing at the directory that contains the built binary. Then from examples/:

(cd ..; export GOBIN=$(pwd); go install) && TF_LOG=WARN TF_VAR_rp_token=rpa_xxxxxxxxxxxx terraform apply

Releases

Packages

Used by

Contributors

Languages