Skip to main content

microvm-ctl

The control and execution plane for AWS Lambda MicroVMs. Build a snapshot image from a Dockerfile, launch Firecracker microVMs in seconds, scale a fleet inside the quotas your account actually has, call into every VM over its authenticated endpoint, watch the whole thing live, and hand a VM a task from Step Functions, Lambda durable functions, or any orchestrator through a lease the VM completes itself. One Python SDK, one mvm command.

ci pypi python license

pip install microvm-ctl          # https://pypi.org/project/microvm-ctl/

mvm bootstrap                              # one time: S3 artifact bucket + build/execution IAM roles
mvm image build my-sandbox ./my-app        # Dockerfile at ./my-app root -> runnable snapshot
mvm run my-sandbox --wait                  # RunMicrovm, then poll to RUNNING
mvm call <microvm-id> /execute -X POST -d '{"code":"print(2+2)"}'
mvm scale my-sandbox 10                    # converge the fleet, throttled to your applied quota
mvm top --watch                            # live state table

To see it used for real first, jump to the eight examples.

Why this exists

Lambda MicroVMs exposes the primitive under Lambda itself: a Firecracker VM with a full AL2023 userland, a dedicated HTTPS endpoint, and a lifecycle you control (run, suspend, resume, terminate). The service deliberately stops there. There is no load balancer (one endpoint per VM), no fleet abstraction, no token management, no dashboard, and a fresh account runs quotas far below the published defaults. microvm-ctl fills that gap.

Concern What the plane does Module
Image factory app directory to zip, to S3, to CreateMicrovmImage, to an ACTIVE version; injects the hook runtime into every image microvm/images.py
Lifecycle and fleets run, suspend, resume, terminate, Fleet.scale_to(n), drain, reap microvm/fleet.py
Quota-aware throttling reads the quotas applied to your account, not the published defaults, and token-buckets every mutating call at 80% of them microvm/fleet.py, microvm/throttle.py
Execution plane mints and caches port-scoped JWE tokens, sets X-aws-proxy-auth, backs off on 429, waits out a 502 while a suspended VM auto-resumes microvm/endpoint.py
In-VM hook runtime zero-dependency server for /ready, /validate, /run, /resume, /suspend, /terminate plus your own routes microvm/hooks/server.py
Observability and cost live fleet table, CloudWatch tail, a cost model that prices a session shape before you commit to it microvm/monitor.py
Account bootstrap artifact bucket plus separate build and execution roles microvm/bootstrap.py
Leases at scale LeasePolicy ceilings, plan with the honest concurrency and worst-case cost, lease_many, mvm lease asl --map, lease_map, mvm watch --image microvm/lease.py, microvm/integrations/
Leases Lease, LeasePolicy, FleetManager.lease: one task per VM, completed by the VM through a task token, callback id, HTTP, SQS, or EventBridge microvm/lease.py
Orchestrator integrations generated Step Functions state machine and IAM (mvm lease asl, mvm lease policy), lease_microvm for Lambda durable functions microvm/integrations/

The lambda-microvms botocore service model ships inside the package, so the plane works on whatever boto3 you already have.

architecture

Measured, not quoted

Every number in this repo comes from the live service in us-east-1. The harness that produced them is benchmarks/benchmark.py; run it against your own account.

What Measured
Image build, Dockerfile to runnable snapshot 123 to 145 s
RunMicrovm to serving authenticated traffic p50 3.54 s, p95 4.49 s
Warm authenticated request (real Python execution inside the VM) p50 111 ms
Explicit suspend / resume 2.5 s / 2.6 s, same PID, state intact
First request to a suspended VM (auto-resume) 200 OK in 0.7 s
Fleet scale-out, 0 to 6 running VMs, on a 1 launch/s quota 9.7 s wall
30 min active + 8 h suspended session vs always-on 93.8% cheaper

benchmark transcript

The SDK in 20 lines

from microvm import PlaneConfig, FleetManager, EndpointClient, Fleet
from microvm.fleet import IdlePolicy

cfg = PlaneConfig()                      # region, profile, bucket, roles from MVM_* env vars
fm = FleetManager(cfg)                   # throttled to your account's applied TPS

vm = fm.run("my-sandbox",
            idle_policy=IdlePolicy(max_idle=300, suspended_for=3600, auto_resume=True),
            run_payload='{"tenant_id": "acme"}')

client = EndpointClient(cfg, vm.microvm_id)
print(client.post("/execute", json={"code": "print(41+1)"}).json())

fleet = Fleet(fm, "my-sandbox")
fleet.scale_to(20, wait_running=True)    # one call, token-bucketed, jittered retries
fleet.suspend_all()                      # park the fleet: snapshot storage billing only
fleet.drain()                            # terminate every member

Inside the VM, declare the lifecycle with the injected hook runtime. There is nothing to install in the image.

from microvm_hooks import HookApp
app = HookApp()

@app.on_ready
def ready(ctx):
    warm_caches()
    return True                          # 200 means "snapshot me now"

@app.on_run
def run(ctx):                            # every clone, before traffic; RNG is reseeded for you
    load_tenant(ctx.get("runHookPayload"))

@app.route("POST", "/execute")
def execute(body, headers):
    return 200, {"out": sandbox_exec(body["code"])}

app.serve(port=8080)

What the CLI looks like

mvm quotas shows the difference between the published defaults and what your account can actually do. This is a fresh account: one launch per second and 8 GB of total microVM memory.

mvm quotas

mvm image ls after building the eight example images from the companion repo.

mvm image ls

mvm cost prices a session shape from the published rates. This is the 30 minutes active plus 8 hours suspended shape on a 2 GB VM with the measured 0.61 GB snapshot.

mvm cost

The playground

mvm playground opens a local web app that drives everything above against the live service: build images, run and scale fleets, call VMs, tail logs, price sessions, run a parameterised benchmark, and watch every AWS API call the process makes in a trace. A dry-run switch turns each mutating action into a printout of the exact request it would send. See docs/playground.md.

mvm playground            # http://127.0.0.1:8765

Documentation

  • Quickstart: from an empty account to a serving VM, with the environment variables explained.
  • CLI reference: every mvm command and flag.
  • SDK reference: PlaneConfig, ImageBuilder, FleetManager, Fleet, EndpointClient, FleetMonitor, CostModel.
  • Architecture: the two planes, the lifecycle state machine, the fleet design decisions, and the security model.
  • The hook contract: what each hook is for and what breaks when you ignore it.
  • Quotas and cost: the quota walls, what counts against them, and the cost model with worked examples.
  • Troubleshooting: the errors I hit on the live service and what each one meant.
  • The playground: the local web app over the whole SDK, and how to host it.
  • Integrations: the lease contract for handing a VM to Step Functions, Lambda durable functions, or your own orchestrator, and what the plane should own.

See it working: thirteen examples and the article series

The fastest way to understand the plane is to read the apps built on it. The companion repo awesome-microvm holds thirteen production-shaped examples, each a Dockerfile plus a single-file app, deployed and recorded on the live service:

Example What it shows
code-sandbox untrusted or AI-written Python per session; state persists across calls and suspend
ai-code-runner Bedrock writes code, the VM runs it, tracebacks drive a self-repair loop
agent-eval Fleet.scale_to fan-out over byte-identical clones, scoreboard, drain
notebook a kernel whose namespace survives suspend and resume with the same PID
data-analytics DuckDB over S3 through the execution role; bulk data off the endpoint
ci-runner clone, test, report, terminate; --max-duration as the runaway cap
pdf-service untrusted HTML rendered in the VM; idle policy sleeps it between bursts
multi-tenant-agents one VM per tenant, identity via runHookPayload, run_payload_factory on a Fleet
handoff-agent the one image every orchestrator leases: on_lease, phases, progress, heartbeats, typed failures, in-VM parallel steps
stepfunctions-handoff runMicrovm.waitForTaskToken machines from mvm lease asl, single lease and a governed Map fan-out
durable-handoff a Lambda durable function leases a VM with lease_with_relaunch and fans out with lease_map
generic-handoff any controller: the same lease over SQS, EventBridge, or an HTTP collector
circuit-breaker running-memory metric, alarm, and Fleet.drain for every image: the account-wide stop behind LeasePolicy

The four-part article series Building on AWS Lambda MicroVMs on the AWS Builder Center walks through them:

  1. Control and scale AWS Lambda MicroVMs with microvm-ctl: this plane and its measurements.
  2. Seven workloads Lambda could never run, until MicroVMs: the first seven examples through build, run, cost, and gotchas.
  3. A kernel for every customer: scaling AI agents to 1,000 tenants on AWS Lambda MicroVMs with microvm-ctl: the multi-tenant finale with the decision guide.
  4. Hand a task to a MicroVM from anywhere: one lease, Step Functions, durable functions, or your own controller: the lease contract, Step Functions, durable functions, your own controller, and leases at scale.

The article sources and a long-form deep dive per example live under awesome-microvm/blog.

Every lease scenario also runs live, on Step Functions and on a Lambda durable function, in microvm-handoff-demo: nine scenarios on both orchestrators plus one lease from the CLI, with the execution histories, VM and orchestrator logs, benchmarks, and console screenshots checked in. Its first pass ran on 0.3.0 and found the two things that became 0.3.1: a typed failure whose VM Step Functions never terminated, and a 30 s heartbeat interval against a 30 s heartbeat timeout that lost a durable callback before the first heartbeat landed.

Requirements and regions

Python 3.9 or newer on the machine running the plane. The VMs themselves are ARM64 (Graviton) only, so audit binary wheels before you build an image. The service is available in us-east-1, us-east-2, us-west-2, eu-west-1, and ap-northeast-1.

Credits and inspiration

This project grew out of lambda-microvm-starter by Alexey Vidanov, the one-command on-ramp that deploys any Dockerfile to a Lambda MicroVM behind a public CloudFront URL. His starter kit and its troubleshooting notes were the first working map of the service I had, and several of the gotchas documented here were first written down there. microvm-ctl takes the next step from one deployed app to fleets, tokens, quotas, and cost, and I am grateful for the ground he covered first.

Contributing

Issues and pull requests are welcome. See CONTRIBUTING.md for the local test loop (no AWS account needed for the unit tests) and the conventions used in this repo.

License

Apache-2.0

Metadata

Release files for microvm-ctl 0.4.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for microvm-ctl 0.4.0
File Size Uploaded
microvm_ctl-0.4.0.tar.gz 165.7 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for microvm-ctl 0.4.0
File Interpreter ABI Platform
microvm_ctl-0.4.0-py3-none-any.whl Python 3 none any Details

Total release size: 295.0 kB

Release files / microvm_ctl-0.4.0.tar.gz

Download URL microvm_ctl-0.4.0.tar.gz
Size 165.7 kB
Tags Source
SHA-256 checksum
How to use checksums
da485134e206c315de83ba8cf912a232e70b841e8377ed5b23f2bb08dbfc231d
BLAKE2b-256 checksum
How to use checksums
35eedcf9a65ac5b64d8e02d8f9d240705f78ac3586008d38cb9661a5baf393a1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 7, 2026.

Transparency log

Release files / microvm_ctl-0.4.0-py3-none-any.whl

Download URL microvm_ctl-0.4.0-py3-none-any.whl
Size 129.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
66b552dc03c9410e7a1f0c9aa59bc418df06ccfbb228eab41fa7a9f40f0f5cfc
BLAKE2b-256 checksum
How to use checksums
5921802ac2677184f088f2f35561161cc6691b180039b98571ccf2ace4c1ebd6
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 7, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

0.4.0 This release

2 release files

0.3.1

2 release files

0.3.0

2 release files

0.2.1

2 release files

0.2.0

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page