Skip to content

Set up a Lambda runner in your AWS account

A Lambda runner group has no machine that stays up. When a run is queued for the group, SREInsights invokes your function once; the function is the runner for that one run. It suits work that runs now and then: nightly collection, a token refresh, a script that used to be a cron job.

You need:

  • an Owner or Admin role in SREInsights,
  • an AWS account where you can create a Lambda function, an ECR repository and a Secrets Manager secret,
  • Docker on some machine, to build the image and to register the function once,
  • the SREInsights source code (deploy/Dockerfile.runner-lambda), from the SREInsights team.

The Lambda runner is built on AWS’s Node.js base image. Lambda takes a single-platform image without attestations, from ECR:

Terminal window
docker buildx build --platform linux/arm64 --provenance=false \
-f deploy/Dockerfile.runner-lambda \
-t 123456789012.dkr.ecr.us-east-1.amazonaws.com/sreinsights-runner-lambda:2026-11-22 --push .

Use a new tag for every build: a function keeps running the image it was created from until you update it.

The image has Node and a shell, and no Docker. To run Python or your own code, extend it:

FROM 123456789012.dkr.ecr.us-east-1.amazonaws.com/sreinsights-runner-lambda:2026-11-22
RUN dnf install -y python3.12 python3.12-pip && dnf clean all
# Which interpreter "python" scripts run on.
ENV SREINSIGHTS_PYTHON=python3.12
COPY requirements.txt .
RUN python3.12 -m pip install --no-cache-dir -r requirements.txt
# Code your script checks call. /var/task and /opt are read-only at run time; write under /tmp.
COPY jobs/ /opt/jobs/

Keep the base image’s handler and entry point; an extension only adds files.

Create a Lambda function from the image, with:

Setting Value
Architecture The one you built (arm64 above)
Timeout Up to 900 seconds. A run still going 20 seconds before the timeout is stopped and reported as timeout.
Memory 1024 MB is a good start. A run costs its duration at this memory.
Asynchronous invocation, retry attempts 0. SREInsights starts a run again itself when it needs to.
Network Outbound HTTPS to your SREInsights URL and to whatever its checks reach.
Permissions Whatever your checks need in AWS (below), plus secretsmanager:GetSecretValue on the identity secret.

Then let SREInsights invoke it: the control plane’s credentials need lambda:InvokeFunction on this function.

  1. Go to Runners and select New runner group.
  2. Runs on: An AWS Lambda function.
  3. Name the group, such as jobs.
  4. Function: its name, name:alias, or ARN. Region: such as eu-west-1.
  5. Select Create group. It shows as Not connected until the function is registered.

On the group, select Connect function, then Create registration command. Run the command once, on any machine with Docker:

Terminal window
docker run --rm \
-e SREINSIGHTS_URL=https://sreinsights.example.com \
-e SREINSIGHTS_REGISTRATION_TOKEN=prt_… \
-e SREINSIGHTS_RUNNER_NAME=jobs-function \
ghcr.io/bintree-softwares/sreinsights-runner:latest identity

It makes the runner’s keys on that machine, registers the public halves, and prints one line starting with sri1.. That line is the function’s identity: its private keys and the SREInsights address it signs in to. It is not stored anywhere else.

To give the function’s runner labels, add -e SREINSIGHTS_RUNNER_LABELS=… to this command. If the function reaches SREInsights at another address, set SREINSIGHTS_URL on the function.

Store the line in AWS Secrets Manager, and point the function at it:

Terminal window
aws secretsmanager create-secret --name sreinsights-runner-jobs/identity --secret-string "sri1.…"
aws lambda update-function-configuration --function-name sreinsights-runner-jobs \
--environment "Variables={SREINSIGHTS_RUNNER_IDENTITY_SECRET=sreinsights-runner-jobs/identity}"

Or set the line directly as SREINSIGHTS_RUNNER_IDENTITY. Whoever holds the identity is this runner: if it leaks, disable the runner on Runners and register again.

The drawer says the function is registered. Runs start once the function has its identity.

Create a monitor or job with Runner group set to your Lambda group and select Run now. The monitor form says “Each run wakes this group’s Lambda function.” The run shows in the history like any other; the function’s own logs are in CloudWatch.

Letting scripts use the function’s AWS role

Section titled “Letting scripts use the function’s AWS role”

Lambda gives a function its role only as environment variables, and a script inherits none of them by default. For scripts that must call AWS as the function (read a secret, write to a bucket), set on the function:

Terminal window
SREINSIGHTS_SCRIPT_ENV_PASSTHROUGH=AWS_ACCESS_KEY_ID,AWS_SECRET_ACCESS_KEY,AWS_SESSION_TOKEN,AWS_REGION
  • 15 minutes per run, AWS’s limit. Script checks are capped at 10 minutes anyway.
  • No runtime: docker scripts. Saving one on a Lambda group is refused.
  • One run per invocation. The group’s concurrency is the function’s.
  • No offline alert. The group shows On demand. Problems show on the runs instead:
Run result Usual cause
error/dispatch_failed SREInsights could not invoke the function: no permission, no such function, wrong region. The result carries AWS’s reason. It fires the monitor’s alert.
skipped/no_runner The function was invoked and did not take the run within 30 seconds or more. Usually it has no identity, can’t reach SREInsights, or lacks the labels the monitor asks for. Look at its CloudWatch logs.
timeout The run outlived the function’s timeout.

Next: Move a scheduled job into SREInsights.