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¶
basic_auth(Attributes) Ask for a user name and a password. (see below for nested schema)redirect_regex(Attributes) Redirect requests whose URL matches a regular expression. (see below for nested schema)redirect_scheme(Attributes) Redirect requests to another scheme, usuallyhttps. (see below for nested schema)strip_prefix(Attributes) Remove a path prefix before the request is passed on. (see below for nested schema)
Read-Only¶
id(String) The ID of this resource.type(String) Which block is set:basicAuth,redirectRegex,redirectSchemeorstripPrefix.
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. Defaultfalse.
Nested Schema for redirect_scheme¶
Required:
scheme(String) Scheme to redirect to, e.g.https.
Optional:
permanent(Boolean) Answer with a permanent redirect. Defaultfalse.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