Bring your own Lambda (BYOL)
Use this when you already ship Lambdas with your CI/CD and want them on the instance rstreams bus (LeoCron schedules, Observe, queue IO) without adopting Studio workflow deploy.
Shared instances are not supported. Self-hosted and managed dedicated instances are.
Must I use a project, deploy, or workflow?
No — not for the function. Register the Lambda on a dedicated instance. Registration creates its bus queues. That is the runtime.
A data product is a catalog row bound to a queue that already exists on the
instance. After workflow deploy or runtime queue reconciliation, the
product’s deployment_bindings.queue_name is the queue handle the SDK and MCP
tools use.
SDK get_writer / get_reader resolve that binding automatically.
The bus is Lambdas registered on LeoCron — platform or yours. Queues exist because those bots exist. Customer BYOL is that same shape: deploy the function, register it, reconcile the catalog onto the queues registration created.
See When to use which for Studio connectors, custom code, and hybrid mixes.
Minimal register (dedicated instance; full steps below):
# Register your already-deployed Lambda on the instance bus (starts paused)
loxtep bots register \
--instance <instance_id> \
--name "My Worker" \
--slug my-worker \
--lambda-name my-company-worker
When to use which
These methods share the same instance bus. Pick per hop — hybrid is normal.
| Method | Use when | Who deploys the code |
|---|---|---|
| BYOL (this guide) | You already ship a Lambda in your CI/CD and want LeoCron, Observe, and catalog bind on its queues | You |
| SDK / connector ingest | A packaged connector (or SDK Event Stream) should pull or push into a source data product as a Trigger at the ingest head | Loxtep workflow deploy for that hop — see Connect Data Sources |
| SDK / connector delivery | A packaged connector should write outbound as a Target at the delivery tail (workflow_type: "delivery") | Loxtep workflow deploy for that hop — see Configuring Delivery (Event Stream / SDK) |
| Studio custom code (MicroVM) | You want Loxtep to host and run custom logic as a graph node (generated bots / MicroVM), not a Lambda you deploy yourself | Loxtep (Studio project / workflow deploy) |
Hybrid. Mix freely on one dedicated instance: connector Trigger → BYOL
Lambda on custom-*-out → connector Target; or Studio custom-code next to a
BYOL bot; or SDK get_reader / get_writer against a catalog product bound to
any of those queues. The join point is the queue name + catalog bind, not a
single project that owns every hop.
Do not retarget a BYOL bot’s source_queue / destination_queue onto Studio
container queues (w-…-queue-…) to “wire” the graph. Bind each data product to
the queue that hop already owns.
Prerequisites
-
A self-hosted or managed instance (not shared).
-
Instance
connection_details.observe_apihas:workflow_deploy_role_arn— used when set. An empty field usescross_account_role_arnexternal_idrstreams_secret_arn/rstreams_auth_arn(for Lambda env)cross_account_role_arn— account key stored on the instance, and the role bot registration assumes whenworkflow_deploy_role_arnis empty
Both role fields empty returns 500
Missing workflow_deploy_role_arn for bot registration. Record the deployment role ARN from the cross-account template.A missingexternal_idreturns 400Instance is missing dedicated BYOL prerequisites: connection_details.observe_api.external_id. Complete self-hosted/managed provisioning (cross-account role + external_id) first.Self-hosted create copies aworkflow_deploy_role_arnalready on the organization registration. The deployment role covers the call whencross_account_role_arnis on the instance. These status codes were read from the handlers and were not called live (unverified). -
Your user has
instances:bots:write(andinstances:bots:readto list / reconcile). Admins and engineers get these by default after the permission seed migration. -
The Lambda lives in the same AWS account and region as the instance bus.
Steps
1. Deploy your function
Deploy with your normal pipeline. A minimal Node handler that loops event
batches is in the platform repo under docs/custom-lambda-bot/template/.
2. Wire bus secrets on the Lambda
From the CLI:
loxtep instances stream-config <instance_id>
Set on the function:
| Env var | Source |
|---|---|
RSTREAMS_CONFIG_SECRET | Resources secret (rstreams_secret_arn) |
LEOAUTH_CONFIG_SECRET | Auth secret (rstreams_auth_arn) |
3. Register with Loxtep
Use the CLI:
loxtep bots register \
--instance <instance_id> \
--name "My Worker" \
--slug my-worker \
--lambda-name my-company-worker
Or call MCP loxtep_workspace with this payload:
{
"operation": "register_custom_bot",
"instance_id": "<uuid>",
"name": "My Worker",
"slug": "my-worker",
"lambda_name": "my-company-worker",
"paused": true
}
Registration defaults to paused. LeoCron paused is the runtime source of
truth after the first create—unpause in Observe when ready.
Bot id: w-{org4}-{inst4}-custom-{slug}. Default queues:
| Role | Name |
|---|---|
| Source | {bot_id}-in |
| Destination (publish) | {bot_id}-out |
| Errors | {bot_id}-errors |
Leave these defaults unless you have a deliberate reason to override them.
4. Attach IAM
The register response includes iam_policy (LeoBot-equivalent). Attach it to
the Lambda execution role (or use the platform LeoBotPolicy pattern). Loxtep
also adds a cron-processor lambda:InvokeFunction permission on your function.
5. Bind a data product to a queue you already have
The catalog follows the queue. It does not retarget your Lambda onto a Studio
workflow hop. Bind the publish stream: {bot_id}-out.
Option A — Runtime queue reconciliation
Requires system:admin, data_products:admin, or instances:update. Admin UI:
/admin/runtime-queue-reconciliation.
- Dry-run first with MCP
loxtep_observe:
{
"operation": "reconcile_runtime_queues",
"instance_id": "<uuid>",
"dry_run": true
}
- Review
orphan_runtime/proposed_runtime_stubs. The live reconciler compares every botmon queue to catalog queue bindings (deployment_bindings.queue_nameon each data product). It does not drop-inor-errorsnames; treat those stubs as not the product and keep the product on-out. - Run with
"dry_run": falsewhen ready. Default stub mode isauto_stub: orphan queues become draft products withbinding_source: reconciled_from_runtimeand a catalog queue binding set. - Stub insert needs an active project (and domain). The runner uses an existing deployment or a DB-only placeholder deployment/workflow. It does not deploy your Lambda and does not write a Studio graph. If the org has no active project, stub insert is skipped.
- List stubs with MCP
loxtep_build(stubs carry thesynthetic_systemtag):
{
"operation": "list_data_products",
"tags": "synthetic_system"
}
Option B — Studio workflow deploy
If the product is created through a Studio project deploy, the deployment
orchestrator sets deployment_bindings.queue_name (usually the workflow output
queue). No manual queue field on the data product is required.
After the product is bound (reconciliation or deploy), SDK
data_products.get_writer / get_reader resolve the bound queue. Pass bot_id
as the custom bot id when the checkpoint should be that bot.
6. Unpause and verify
- In Observe, find bot id
w-{org4}-{inst4}-custom-{slug}and unpause. - Optionally reconcile CLI drift against LeoCron:
loxtep bots reconcile --instance <instance_id>
The same check is available from MCP loxtep_workspace:
{
"operation": "reconcile_custom_bots",
"instance_id": "<uuid>"
}
Do and don't
Do
- Deploy the Lambda in the same AWS account and region as the instance bus.
- Register paused, attach the returned
iam_policy, setRSTREAMS_CONFIG_SECRETandLEOAUTH_CONFIG_SECRETfrom stream-config. - Leave the default
custom-*queues; bind the data product to{bot_id}-out. - Loop every event in a batch; write flat business objects; flush streams once per invoke.
- Dry-run reconciliation before stubbing; pass the custom
bot_idinto SDK reader/writer when checkpointing as that bot. - Unpause in Observe (LeoCron
pausedis runtime source of truth after create). - Deregister only when you want the cron row archived — your Lambda stays.
Don't
- Use a shared instance, a Lambda ARN in another account, or register a
Loxtep
*-rtime/ platform microservice function name. - Treat
package.jsonpausedas live status, or expect deregister to delete the function or the data product. - Take only
payload[0], callendStreamAsyncper event, or hand-buildcorrelation_id. - Point this bot’s
source_queue/destination_queueat a Studio container queue (w-…-queue-…-ingestedand the rest) to “join” a graph. Catalog binding follows the queue your bot already owns. - Promote
-inor-errorsstubs as the product; the live reconciler does not drop them.
Day-2 operations
| Action | CLI | MCP loxtep_workspace operation |
|---|---|---|
| List | loxtep bots list --instance … | list_custom_bots |
| Get | loxtep bots get --instance … --bot-id … | get_custom_bot |
| Update / rename Lambda | loxtep bots update … | update_custom_bot |
| Deregister | loxtep bots deregister … | deregister_custom_bot |
Deregister archives the LeoCron row and removes the cron-invoke Sid. Your Lambda code is never deleted.
On Lambda rename, Loxtep re-grants invoke on the new function and removes the Sid from the previous one.
Custom bots and project bots share the Observe namespace w-{org4}-{inst4} and
are tagged custom-lambda and byol. Instance and workflow deploys do not
replace the customer function.
What this is not
- Zip upload / Loxtep-owned deploy of your code into the account
- Cross-account Lambda ARN invoke from a different account than the bus
- Replacing connector ingest/delivery or Studio custom-code MicroVM — those remain available; see When to use which
Related
- Instance provisioning: Instance Provisioning
- Connector ingest: Connect Data Sources
- Connector / SDK delivery: Configuring Delivery
- Runtime queue → catalog link (operators):
docs/operations/runtime-queue-link-queue-workflow.md - Engineering ADR:
docs/ADR/0011-custom-lambda-bot-registration.md - Handler template + CLI contract:
docs/custom-lambda-bot/