Function Operation
The Function operation executes JavaScript/TypeScript code synchronously via the Function Service. Functions return results directly and are ideal for custom business logic that cannot be expressed in GraphQL, data transformations, integration with external APIs, and complex calculations.
For more details on writing functions, refer to the Function Service documentation.
Configuration Example
executor_function.tf
resource "tailor_executor" "function_executor" {
workspace_id = tailor_workspace.ims.id
name = "function-executor"
description = "Execute synchronous function"
trigger = {
# Choose one of the trigger types:
# event = { ... }
# webhook = { ... }
# schedule = { ... }
}
operation = {
function = {
name = "processData"
script = file("${path.module}/scripts/process_data.js")
variables = <<EOF
({
"data": args.record,
"timestamp": (new Date()).toISOString()
})
EOF
}
}
}
Properties
Executor Properties
Property | Type | Required | Description |
---|---|---|---|
name | string | Yes | The name of the executor. The name field has the validation rule ^[a-z0-9][a-z0-9-]{1,61}[a-z0-9]$ , and it does not allow capital letters |
workspace_id | string | Yes | The ID of the workspace that the executor namespace belongs to |
description | string | No | The description of the executor |
trigger | object | Yes | The type of trigger (webhook, event, or schedule) |
Function Operation Properties
Property | Type | Supports Scripting | Required | Description |
---|---|---|---|---|
name | string | - | Yes | The name of the function |
script | string | - | Yes | The JavaScript/TypeScript code to execute |
invoker | object | - | No | The invoker of the operation |
variables | string | JavaScript / CEL | No | The variables to pass to the function. Can access trigger-specific data via args object |