Functions

Invoke isolated services from committed events.

Trestle dispatches selected event topics to AWS Lambda through its durable job boundary. Application transactions never wait for function execution.

Configure a target

Open Integrations → AWS Lambda, then provide a name, function ARN, region, subscribed topics and any callback scopes required by the handler.

Name: Enrich new issues
Function ARN: arn:aws:lambda:ap-southeast-2:123456789012:function:enrich-issue
Region: ap-southeast-2
Topics: record.created
Callback scopes: records:read,records:write

Delivery path

  1. The application transaction changes state.
  2. The same transaction records its event and outbox job.
  3. A worker claims the committed job with a finite lease.
  4. Trestle signs an asynchronous Lambda invocation with process-held AWS credentials.
  5. HTTP 202 records provider acceptance; retries and diagnostics remain in the job record.

Function envelope

{
  "version":"1",
  "eventId":"evt_...",
  "topic":"record.created",
  "collection":"issues",
  "recordId":"rec_...",
  "occurredAt":"2026-08-27T04:30:00Z",
  "payload":{}
}

Idempotent handler

export const handler = async event => {
  if (await alreadyHandled(event.eventId)) return;
  const issue = await trestle.records.get(event.collection, event.recordId);
  await enrich(issue);
  await markHandled(event.eventId);
};

Invocation is at least once. Use the stable event ID as an idempotency key. A 202 response means AWS accepted the event, not that the handler completed successfully.

Credentials and callbacks

AWS credentials stay in Trestle process configuration and are never exposed in the dashboard. Callback credentials must be narrower than an administrator session and limited to the scopes the handler needs.

Why no local scripts?

Trestle does not execute arbitrary user code inside the server process. A credible local runtime would require a separate worker boundary, resource limits, capabilities, secret isolation and cancellation rather than an unsafe convenience hook.