RunR v0.5.7

Documentation

runr_project (Resource)

A RunR project: a function (faas), a single-file script (xaas) or a container (caas) in a region. Code is uploaded with runr deploy; container images and deployments can be managed with runr_deployment.

A config change saves a new project version; running deployments pick it up when they are redeployed (see runr_deployment.triggers).

Example Usage#

data "runr_region" "eu" {
  name = "eu-1"
}

# A Python function; its code is uploaded with `runr deploy`.
resource "runr_project" "api" {
  name      = "orders-api"
  type      = "faas"
  runtime   = "python"
  region_id = data.runr_region.eu.id
  handler   = "main.handler"

  resources = {
    cpu             = "250m"
    memory_mb       = 256
    timeout_seconds = 30
  }

  scale = {
    min     = 0
    max     = 10
    to_zero = true
  }

  trigger = {
    type = "http"
  }
}

# A nightly job.
resource "runr_project" "report" {
  name      = "nightly-report"
  type      = "faas"
  runtime   = "nodejs"
  region_id = data.runr_region.eu.id

  trigger = {
    type     = "schedule"
    schedule = "0 2 * * *"
  }
}

# A container.
resource "runr_project" "web" {
  name      = "web"
  type      = "caas"
  region_id = data.runr_region.eu.id
  image     = "ghcr.io/acme/web:1.4.2"
  ports     = [8080]

  # Let runr_deployment (or CI) roll out new images.
  lifecycle {
    ignore_changes = [image]
  }
}

Schema#

Required#

  • name (String) Project name; its slug names the service and the default URL. Changing it creates a new project.
  • region_id (String) Region id (data.runr_region). Changing it moves the project.
  • type (String) faas, xaas or caas. Changing it creates a new project.

Optional#

  • args (List of String) caas: arguments.
  • command (List of String) caas: entrypoint override.
  • description (String) Free text.
  • filename (String) xaas: the script file (default main.<ext>).
  • handler (String) faas: file.function (default main.handler → main.py, def handler). xaas: the function name (default handler).
  • image (String) caas: container image. Required when the project is created.
  • ports (List of Number) caas: container ports; the first serves HTTP (default 80).
  • resources (Attributes) Container limits. (see below for nested schema)
  • runtime (String) Runtime of faas/xaas projects: python, nodejs, go, php, … Changing it creates a new project.
  • runtime_version (String) Runtime version; default the platform's default version. Changing it creates a new project.
  • scale (Attributes) Autoscaling range. (see below for nested schema)
  • trigger (Attributes) What starts the code. (see below for nested schema)

Read-Only#

  • endpoint_url (String) Public URL (HTTP trigger).
  • id (String) Project id.
  • latest_version_id (String) Id of the newest version.
  • slug (String) Slug derived from the name.

Nested Schema for resources#

Optional:

  • cpu (String) Kubernetes CPU quantity (100m, 0.5).
  • memory_mb (Number) Memory in MB (at least 64).
  • timeout_seconds (Number) Request timeout in seconds.

Nested Schema for scale#

Optional:

  • max (Number) Maximum instances (1-1000).
  • min (Number) Minimum instances (0-10).
  • to_zero (Boolean) Scale to zero instances when idle.

Nested Schema for trigger#

Optional:

  • queue (String) Redis stream of a queue trigger (the region needs Redis).
  • schedule (String) Cron expression of a schedule trigger, e.g. */5 * * * *.
  • type (String) http (default), schedule or queue.

Import#

Import is supported using the following syntax:

The terraform import command can be used, for example:

# A project is imported by name or id.
terraform import runr_project.api orders-api

RunR v0.5.7 · MIT License