skip to content
wihan.dev
view as markdown
browse the dokploy docs

dokploy_redirect (Resource)

A Traefik regex redirect on a Dokploy application.

~> Redirects are not unique. Dokploy allows two identical redirects on one application, and redirects.create does not return the new record. The provider therefore identifies a new redirect from a comparison of the redirect list of the application before and after the call. A redirect from the Dokploy UI during an apply can make that comparison ambiguous, and the provider errors rather than guessing.

Example Usage

terraform
resource "dokploy_redirect" "legacy_blog" {
  application_id = dokploy_application.web.id
  regex          = "^/blog/(.*)"
  replacement    = "/posts/$1"
  permanent      = true
}

Schema

Required

  • application_id (String) Id of the application that owns this record. A change forces a replacement: the Dokploy update endpoint for this record type has no parent field, so a record cannot move between applications.
  • regex (String) Path regex to match, for example ^/old/(.*).
  • replacement (String) Replacement path, for example /new/$1.

Optional

  • permanent (Boolean) Issue a permanent redirect (308) instead of a temporary one (307).

Read-Only

  • id (String) Record id.

Import

Import is supported using the following syntax:

In Terraform v1.5.0 and later, the import block can be used with the id attribute, for example:

terraform
import {
  to = dokploy_redirect.legacy_blog
  id = "r1a2b3c4d5e6f7g8h9i0j"
}

The terraform import command can be used, for example:

shell
terraform import dokploy_redirect.legacy_blog r1a2b3c4d5e6f7g8h9i0j