RunR v0.7.5

Documentation

runr_workflow_trigger (Resource)

One trigger of a durable workflow: an event (with an optional condition), a cron schedule or a queue stream. Exactly one of event, cron and queue is set.

The workflow must exist and be declared through the API (runr_workflow without triggers, runr workflows declare, PUT /api/projects/{project}/workflows) or by runr.workflows.json; the resource adds its trigger to the definition and leaves the definition's other triggers and options as they are (PUT /api/projects/{project}/workflows/{workflow}: the project's other definitions are not touched). Workflows whose definitions the function's SDK reports get their triggers from the code: change them there.

Example Usage#

# The workflows are declared through the API, e.g. `runr workflows declare -f runr.workflows.json`.

# Start process-order for large orders.
resource "runr_workflow_trigger" "large_orders" {
  project_id = runr_project.orders.id
  workflow   = "process-order"
  event      = "order.created"
  condition  = "event.data.total > 1000"
}

# Every message of the project's queue stream "orders" starts a run.
resource "runr_workflow_trigger" "orders_queue" {
  project_id = runr_project.orders.id
  workflow   = "process-order"
  queue      = "orders"
}

# The nightly report at 03:00 Istanbul time.
resource "runr_workflow_trigger" "nightly" {
  project_id = runr_project.orders.id
  workflow   = "nightly-report"
  cron       = "0 3 * * *"
  timezone   = "Europe/Istanbul"
}

Schema#

Required#

  • project_id (String) Project id.
  • workflow (String) Workflow name.

Optional#

  • condition (String) Expression the event must satisfy (if), e.g. event.data.total > 100; event and queue triggers.
  • cron (String) Five-field cron expression; the engine starts one run per due minute.
  • event (String) Event name that starts a run, e.g. order.created (letters, digits and . _ : / -).
  • queue (String) Redis stream of the project's queue bridge; each message starts a run (event queue/<stream>).
  • timezone (String) IANA time zone of cron, e.g. Europe/Istanbul (default UTC).

Read-Only#

  • id (String) <project_id>/<workflow>/<event:NAME | queue:STREAM | cron:EXPRESSION[@TIME_ZONE]>.

Import#

Import is supported using the following syntax:

The terraform import command can be used, for example:

# <project name or id>/<workflow>/<event:NAME | queue:STREAM | cron:EXPRESSION[@TIME_ZONE]>
terraform import runr_workflow_trigger.large_orders orders-api/process-order/event:order.created
terraform import runr_workflow_trigger.nightly 'orders-api/nightly-report/cron:0 3 * * *@Europe/Istanbul'

RunR v0.7.5 · MIT License