dev.baschen.is

Ephemeral GitHub runners on Lambda MicroVMs

Self-hosted GitHub Actions runners usually mean a fleet of long-lived machines that every repository shares. This project goes the other way: every job gets a fresh Firecracker VM in your own VPC, runs for at most an hour, can read only its own repository's secrets, and is then destroyed.

The problem

Regulated landing zones tend to have the same shape: workload accounts with no NAT gateway, all egress going through a Transit Gateway to a central, inspected exit, and AWS APIs reached through VPC endpoints. GitHub-hosted runners sit outside all of that. Classic self-hosted runners sit inside it, but they are shared and they live a long time, so one job can leave something behind for the next, and a runner that serves several repositories can see all their secrets.

AWS Lambda MicroVMs offer a better unit: a Firecracker VM you start on demand, attached to your subnets, billed per second, with no idle cost. One job per VM is cheap enough to be the default.

Design decisions

Three modules, two owners

The platform team applies bootstrap once per account and Region: KMS key, buckets, the egress connector, the GitHub OIDC provider, the generic boundary, the repository registry and deploy roles, the token broker and a platform dashboard. An organization admin applies org-guardrails once: the SCP, RCP and tag policy that make the repository tags trustworthy. Each repository then applies runner-image and repo-runner from its own workflow: the image, a webhook, a queue, a dispatcher, a sweeper, a state table, the runner role and its alarms.

A job, from queued to terminated

  1. GitHub calls the webhook. A Lambda Function URL verifies the HMAC signature of the workflow_job: queued event and puts it on an SQS queue.
  2. The dispatcher claims the job. A DynamoDB conditional write on the job id means a duplicate webhook delivery never launches a second VM.
  3. The broker hands out a scoped token. The dispatcher presents a presigned STS call; the broker checks the caller is that repository's control role and returns a token for that repository only.
  4. A one-time runner config is stored. The dispatcher asks GitHub for a just-in-time runner config and writes it to an SSM SecureString parameter.
  5. The MicroVM starts. Its payload is only the parameter name. The supervisor inside reads the parameter, deletes it, starts Docker and runs exactly one job.
  6. The job completes and the VM is terminated. Backstops cover the rest: a sweeper every two minutes, deregistration, a ten-minute idle limit and a 65-minute hard limit.

The VM never sees the App key or an installation token. If a webhook is lost, the sweeper finds jobs that have waited more than two minutes and requeues them.

What the runner role is for

Every job, pull requests included, runs with the repository's runner role, which can read that repository's CI secrets and nothing else. Production credentials do not come from that ambient role: they come from GitHub OIDC, bound to protected Environments.

Where it stands

Version 0.1.0 is released, with release assets, an SBOM and build provenance that consumers check with gh attestation verify before terraform apply. It has been tested against real AWS and a real GitHub workflow: unit tests, IAM policy simulation, a sandbox smoke test, an end-to-end run through both deploy paths, a real job and drills for capacity, VM failure and lost webhooks. The sandbox is torn down after every run, so nothing runs between tests.

You need Terraform 1.11 or later, a Region where Lambda MicroVMs are available, a GitHub App with Administration: write and Actions: read, and private subnets that can reach central egress.

← All articles