Skip to content

rso_middleware (Resource)

A middleware changes requests on their way through an rso_ingress_route: it asks for a password, redirects, or strips a path prefix. Set exactly one of the four blocks. The API has no update, so every change replaces the middleware.

Example Usage

# Redirect plain HTTP to HTTPS.
resource "rso_middleware" "to_https" {
  name = "to-https"

  redirect_scheme = {
    scheme    = "https"
    permanent = true
  }
}

# Ask for a password.
resource "rso_middleware" "admin_auth" {
  name = "admin-auth"

  basic_auth = {
    username = "admin"
    password = var.admin_password
  }
}

# Use it in a rule of an ingress route.
resource "rso_ingress_route" "admin" {
  name = "admin"

  routes = [{
    match       = "Host(`app.example.com`) && PathPrefix(`/admin`)"
    middlewares = [rso_middleware.admin_auth.name]
    services = [{
      external_service = rso_external_service.web.name
      port             = 80
    }]
  }]
}

Schema

Required

  • name (String) Middleware name, unique within the tenant; ingress routes refer to it by this name.

Optional

Read-Only

  • id (String) The ID of this resource.
  • type (String) Which block is set: basicAuth, redirectRegex, redirectScheme or stripPrefix.

Nested Schema for basic_auth

Required:

  • password (String, Sensitive) Password. It is sent to the platform and never read back.
  • username (String) User name.

Nested Schema for redirect_regex

Required:

  • regex (String) Regular expression matched against the request URL.
  • replacement (String) URL to redirect to; ${1} refers to the first capture group.

Optional:

  • permanent (Boolean) Answer with a permanent redirect. Default false.

Nested Schema for redirect_scheme

Required:

  • scheme (String) Scheme to redirect to, e.g. https.

Optional:

  • permanent (Boolean) Answer with a permanent redirect. Default false.
  • port (String) Port to redirect to, when not the scheme's default.

Nested Schema for strip_prefix

Required:

  • prefixes (List of String) Prefixes to remove, e.g. ["/api"].

Import

Import is supported using the following syntax:

# Import a middleware by its name. The password of a basic_auth middleware
# is never returned, so such a middleware is replaced on the next apply.
terraform import rso_middleware.to_https to-https