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
- One job, one VM. Jobs are capped at one hour (configurable), well inside the eight-hour MicroVM limit. The VM is terminated when the job completes.
- Everything inside your VPC. Lambdas and MicroVMs use private subnets. The
VMs attach through a
VPC_EGRESSconnector, neverINTERNET_EGRESS, so their traffic follows your routes to central egress and inspection. - Each repository deploys its own runners, from its own workflow, into its target account. There is no central fleet to size.
- A platform-owned token broker. Only the broker can read the GitHub App
private key. A repository proves its IAM identity with a presigned STS
GetCallerIdentitycall and gets a one-hour installation token scoped to its own repository. - One ABAC boundary per account. Every repository's roles carry a
gha-repo-idtag. A single, fixed-size permissions boundary scopes them togha-microvm-<repo-id>-*through policy variables, and organization SCPs keep the tags honest, so repositories sharing an account cannot touch each other. - One MicroVM image per repository. The terminate permission is scoped to an image ARN, so a repository's dispatcher can only kill its own VMs. arm64 (Graviton) is the default; x64 is available per repository.
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
- GitHub calls the webhook. A Lambda Function URL verifies the HMAC signature of
the
workflow_job: queuedevent and puts it on an SQS queue. - The dispatcher claims the job. A DynamoDB conditional write on the job id means a duplicate webhook delivery never launches a second VM.
- 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.
- 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.
- 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.
- 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.