AWS Lambda Microvms
AWS LabsOfficialPublished by AWS Labs
- Skill
- Tool integration
- Cloud and DevOps
- Apache-2.0
- Low risk
AutoGineer summary
Written by AutoGineer from the skill’s own files, not by the author
AWS Lambda MicroVMs provide a serverless compute environment that combines the security of Firecracker VM isolation with the efficiency of containers. Designed for workloads requiring long-lived sessions, state persistence, or custom networking, these MicroVMs support up to 8-hour lifetimes and feature snapshot-based booting for rapid startup. The platform uses a two-resource model (MicrovmImage and Microvm) and supports lifecycle hooks for fine-grained control over application state, making it ideal for interactive sandboxes, simulations, and session-affine services.
What it does
- Builds containerized applications into snapshot-resumable MicroVM images.
- Supports lifecycle hooks for custom application initialization and state management.
- Provides secure, TLS-terminated HTTPS endpoints for running instances.
- Enables suspend and resume functionality to preserve state across inactivity.
- Allows for advanced networking, including port-listening servers and shell ingress.
- Integrates with IAM roles for secure build-time and runtime permission management.
When to use it
- When you need isolated compute for AI/agent code execution sandboxes.
- For interactive code playgrounds, Jupyter notebooks, or REPL environments.
- When running sessionful game servers or long-lived simulations.
- For multi-tenant CI executors or isolated security scanning tools.
- When your workload requires custom syscalls, eBPF, or persistent state across sessions.
Advantages
- Strong tenant isolation via Firecracker microVMs.
- Fast startup times through memory and disk snapshotting.
- State preservation via suspend/resume capabilities.
- Support for long-lived sessions up to 8 hours.
- Container-like development workflow using Dockerfiles.
Usage examples
- “How do I create a new MicroVM image from my Dockerfile?”
- You package your Dockerfile and code into a zip, upload it to S3, and use the create-microvm-image command with your build role and base image ARN.
- “How can I access a running MicroVM via a shell?”
- Enable SHELL_INGRESS in your network connectors, mint a shell auth token, and connect via a WebSocket to the endpoint using the provided subprotocol.
- “How do I ensure my app is ready before a snapshot is taken?”
- Implement the /ready lifecycle hook in your application; the platform will wait for a 200 status code before finalizing the snapshot.
Install
Download the skill as a ZIP:
https://mp-staging.autogineer.com/agent-skills/awslabs/aws-lambda-microvms/downloadUnzip it into the cross-client skills folder of your project:
mkdir -p .agents/skills && unzip aws-lambda-microvms.zip -d .agents/skills
Documentation by AWS Labs
AWS Lambda MicroVMs
The AWS MCP server is recommended for sandboxed execution and audit logging.
AWS Lambda MicroVMs are serverless compute environments that combine Firecracker VM isolation with container-like efficiency. Each MicroVM:
Runs your application as a container inside a Firecracker microVM — you can reproduce the environment locally.
Runs Amazon Linux 2023 as the base OS inside the MicroVM.
Boots from a memory + disk snapshot captured at image build time, so application init is skipped on run.
Has a dedicated, TLS-terminated HTTPS endpoint reachable with an auth token.
Can be suspended and resumed with state preserved; lives up to 8 hours.
Two-resource model:
MicrovmImage— a versioned artifact built from{S3 zip with Dockerfile} + baseImageArn. Each version has per-architecture/chipsetBuilds.Microvm— a running instance created (RunMicrovm) from an image version.
Two roles:
buildRoleArn— used during image build (S3 read, CloudWatch logs, optional ECR).executionRoleArn— assumed at runtime by the running MicroVM.
When to use
Choose Lambda MicroVMs when
Analytics workloads — isolated compute for data processing, ETL jobs, or query execution with strong tenant separation.
AI / agent code execution sandboxes — fresh, isolated environment per session, fast resume between turns.
Interactive code playgrounds & notebooks — Jupyter, REPLs, dev environments executing user code.
Reinforcement-learning environments — clean per-episode envs with tool access.
Multi-tenant CI executors / build runners — strong tenant isolation.
Game / simulation servers — sessionful, long-lived (up to 8 hr) workloads.
Security scanning — running untrusted analyzers in isolation.
In general, Lambda MicroVMs are suited for long-lived sessions, real port-listening servers (gRPC, WebSocket, custom TCP protocols), state preserved across periods of inactivity (suspend/resume), container-level access (FUSE, eBPF, custom syscalls), or session-affine routing to a specific compute environment.
Choose AWS Lambda (functions) when
The workload fits in 15 minutes.
Per-invocation isolation is fine; no need for session state held in memory.
Fully automatic scaling is preferred (no
RunMicrovmto manage).Event-source integrations (S3, SQS, EventBridge, etc.) drive the function.
Choose something else when
Continuous compute beyond 8 hr → ECS / EKS / EC2.
Lift-and-shift workloads needing kernel modifications or a non-Linux OS → EC2.
Typical workflow
Check regional availability — confirm Lambda MicroVMs is available in your target region (run
aws lambda-microvms list-managed-microvm-images). Your S3 artifact bucket and any network connectors must be in the same region as the image.Package an app: zip with a
Dockerfileat the root, upload to S3 (same region as the image).Implement lifecycle hooks (optional but recommended) — HTTP endpoints on a port you specify (commonly
9000) for/run,/resume,/suspend,/terminate,/ready,/validate.CreateMicrovmImage — pointing at the S3 artifact, a managed base image, and a build role. Lambda compiles the Dockerfile into an OCI image, starts your app, calls
/ready, snapshots disk + memory, optionally validates with/validate. Lambda will periodically release new managed image versions, and customers should re-build using the latest version to ensure they have up to date images.RunMicrovm — pick an image version, attach
executionRoleArn, setidlePolicy, ingress/egress connectors, and (optionally) arunHookPayload. Receive anendpointURL andmicrovmId.CreateMicrovmAuthToken — get an auth token (max 60 min) with
allowedPortsspecifying which ports the token grants access to. Send traffic to the endpoint withX-aws-proxy-auth: <token>.Suspend / Resume / Terminate — explicit APIs, or let the
idlePolicydrive it (maxIdleDurationSeconds,suspendedDurationSeconds,autoResumeEnabled).
Core CLI commands
# Create an image (zip with Dockerfile at root in S3, plus a managed base image)
aws lambda-microvms create-microvm-image \
--name my-image \
--base-image-arn arn:aws:lambda:<region>:aws:microvm-image:al2023-1 \
--build-role-arn arn:aws:iam::<acct>:role/MicroVMBuildRole \
--code-artifact '{"uri":"s3://<bucket>/<key>.zip"}'
# Run a MicroVM (returns endpoint + microvmId). --image-identifier takes the
# image ARN (the bare name is rejected); --image-version is the full major.minor string.
aws lambda-microvms run-microvm \
--image-identifier arn:aws:lambda:<region>:<acct>:microvm-image:my-image \
--image-version 1.0 \
--execution-role-arn arn:aws:iam::<acct>:role/MicroVMExecutionRole \
--idle-policy '{"maxIdleDurationSeconds":900,"suspendedDurationSeconds":300,"autoResumeEnabled":true}'
# Mint an auth token and call the endpoint
TOKEN=$(aws lambda-microvms create-microvm-auth-token \
--microvm-identifier microvm-... --expiration-in-minutes 30 \
--allowed-ports '[{"port":8080}]' \
--query 'authToken."X-aws-proxy-auth"' --output text)
curl "<endpoint>/" -H "X-aws-proxy-auth: $TOKEN"
# Lifecycle
aws lambda-microvms suspend-microvm --microvm-identifier microvm-...
aws lambda-microvms resume-microvm --microvm-identifier microvm-...
aws lambda-microvms terminate-microvm --microvm-identifier microvm-...See references/getting-started.md for the full walkthrough including --hooks config and lifecycle hooks.
Hook configuration
Hooks are organized into two groups under the --hooks parameter:
microvmImageHooks (build-time)
Recommendation: Implement the image build hooks (
/readyand/validate) for best performance. They enable the platform to capture a complete snapshot and prefetch the portions accessed at run time.
| Hook | Purpose | Timeout range |
|---|---|---|
ready | Called during application boot. When this hook returns a 200 status code, it signals to the platform that the application is ready to be snapshotted. Use this to ensure your application is fully booted before a snapshot is taken. If your application is not yet ready, return a 503 status code until it is ready for snapshotting. | 1–3600s (default 30s) |
validate | Called after running your application from the microVM snapshot. Use this hook to validate the application is ready to serve traffic. This hook additionally allows the platform to sample the portions of the snapshot that are used when your application is ran, allowing Lambda to prefetch those portions of the snapshot to reduce latency. To get the best performance, run mock payloads through the application during validate. When this hook returns a 200, it signals to the Lambda the MicroVM image is valid. If your application needs more time to run its validate workflow, return a 503 status code. | 1–3600s (default 30s) |
Why implement
/ready? It signals the platform that your application has fully booted. Without it, the snapshot may be taken mid-initialization, meaning the cached state is incomplete and every run repeats part of the boot sequence.Why implement
/validate? It lets the platform verify the snapshot is correct, and also samples which portions of the snapshot are accessed duringRunMicrovm. This allows the platform to prefetch those portions on future launches, reducing cold-start times.
microvmHooks (runtime)
| Hook | Purpose | Timeout range |
|---|---|---|
run | Fires once after run from snapshot | 1–60s (default 1s) |
resume | Fires after SUSPENDED → RUNNING | 1–60s (default 1s) |
suspend | Fires before RUNNING → SUSPENDED | 1–60s (default 1s) |
terminate | Fires before termination | 1–60s (default 1s) |
See references/getting-started.md for a full example enabling all hooks.
Per-MicroVM size limits
| Resource | Limit |
|---|---|
| Maximum vCPUs per MicroVM | 16 |
| Maximum memory per MicroVM | 32 GB |
For all other quotas — concurrent MicroVMs per account, launch rate, image count, max execution duration, auth token TTL, Lambda Network Connector (LNC) limits, per-ENI bandwidth, etc. — check the AWS docs / Service Quotas console. Most are soft quotas, raisable through Service Quotas / Support.
Additional capabilities
By default, the container runs with a restricted set of Linux capabilities. Set --additional-os-capabilities '["ALL"]' at image creation time only when required by your use case:
Filesystem mounts — EFS, FUSE-based filesystems.
Nested containers — running additional containers with containerd inside the MicroVM.
eBPF programs — tracing, profiling, or custom network policies.
aws lambda-microvms create-microvm-image \
--name my-image \
--base-image-arn arn:aws:lambda:<region>:aws:microvm-image:al2023-1 \
--build-role-arn arn:aws:iam::<acct>:role/MicroVMBuildRole \
--code-artifact '{"uri":"s3://<bucket>/<key>.zip"}' \
--additional-os-capabilities '["ALL"]'Shell ingress for agent use cases
For programmatic shell access (agent workflows, remote command execution), use the SHELL_INGRESS network connector:
# 1. Run with SHELL_INGRESS enabled
aws lambda-microvms run-microvm \
--image-identifier arn:aws:lambda:<region>:<acct>:microvm-image:my-image \
--execution-role-arn arn:aws:iam::<acct>:role/MicroVMExecutionRole \
--ingress-network-connectors '["arn:aws:lambda:<region>:aws:network-connector:aws-network-connector:SHELL_INGRESS"]' \
--idle-policy '{"maxIdleDurationSeconds":900,"suspendedDurationSeconds":300,"autoResumeEnabled":true}'
# Response includes microvmId and endpoint
# 2. Mint a shell auth token (max 60 min; use shortest duration needed)
# Treat the token as a secret — avoid logging, storing in files, or shell history.
TOKEN=$(aws lambda-microvms create-microvm-shell-auth-token \
--microvm-identifier microvm-... \
--expiration-in-minutes 15 \
--query 'authToken."X-aws-proxy-auth"' --output text)
# 3. Connect via WebSocket (port 8022)
# CLI args are visible in process listings (ps aux). For shared hosts,
# pipe the header via a file descriptor or use a wrapper script.
websocat "wss://<endpoint>/shell" \
-H "Sec-WebSocket-Protocol: lambda-microvms.authentication.${TOKEN}, lambda-microvms, lambda-microvms.port.8022"The shell drops into the same container as the running application — same network namespace, filesystem, and process tree. This provides an interactive PTY over a WebSocket-based shell channel accessible from any client (terminal or browser), suitable for agent-driven workflows that need to execute commands inside the MicroVM.
Prerequisites: MicroVM must be run with SHELL_INGRESS attached, and caller also needs lambda:CreateMicrovmShellAuthToken.
Known constraints
Image is single-size — you can't ship multiple instance sizes from one image. Plan one image per size.
Image versions incur storage cost even when no MicroVMs are running on them. Use
delete-microvm-image-versionto clean up.Suspend → resume can't switch network connectors. LNC is bound at run time.
No self-suspend from inside the MicroVM. Call
SuspendMicrovmfrom outside (via the public API).Auth token max TTL is 60 min. Refresh ahead of expiry for long-running clients.
Runtime hooks (
/run,/resume,/suspend,/terminate) are fast-notification only (1–60s timeout). Don't use them for slow init.
Reference index
Pick the reference that matches your task:
references/getting-started.md— prerequisites (S3 bucket, build role trust policy), packaging, end-to-end CLI walkthrough, first run + token + curl.references/lifecycle-model.md— image vs. MicroVM state machines, the six lifecycle hooks (paths, timeouts, what to do in each), idle/suspend/resume semantics, hook payloads.references/snapshots-and-uniqueness.md— what gets snapshotted, the uniqueness pitfall, CSPRNGs by language, env vars vs. run configuration, snapshot size inspection.references/networking.md— ingress vs. egress connectors, port routing,X-aws-proxy-*headers, WebSocket subprotocols, HTTP/2 / gRPC, VPC egress.references/iam-and-security.md— build role vs. execution role, trust policies, auth tokens (regular vs. shell),lambda:PassNetworkConnector.references/troubleshooting.md— image build error codes, run/connect failures, hook timeouts, network connector issues, debugging via shell access.
Conventions used in references
The runtime-side default proxy port is
8080. Override per-request withX-aws-proxy-portor per-WebSocket with subprotocollambda-microvms.port.<n>.
Security considerations
Confused deputy prevention — add
aws:SourceAccount(oraws:SourceArn) condition keys to trust policies. Seereferences/iam-and-security.md.Snapshot uniqueness — snapshots share memory state. Reseed CSPRNGs and rotate secrets on resume. See
references/snapshots-and-uniqueness.md.Network isolation — use VPC egress connectors to restrict outbound traffic.
Least-privilege execution roles — scope IAM policies to specific regions, accounts, and resource prefixes.
Logging — enable CloudTrail for MicroVM lifecycle events.
Files
- ATTRIBUTION.mdAdded by AutoGineer924 B
- LICENSELicence file added by AutoGineer9.9 KiB
- NOTICELicence file added by AutoGineer89 B
- SKILL.md16.0 KiB
- references/getting-started.md8.7 KiB
- references/iam-and-security.md6.6 KiB
- references/lifecycle-model.md10.7 KiB
- references/networking.md9.2 KiB
- references/snapshots-and-uniqueness.md7.5 KiB
- references/troubleshooting.md12.9 KiB
references/lifecycle-model.md
Lifecycle model
Two state machines (image and MicroVM) plus the lifecycle hook contract your application can optionally implement.
Image state machine
Image-level state:
CREATING ──▶ CREATED ──▶ DELETINGVersion-level state (state + status):
state: PENDING ──▶ IN_PROGRESS ──▶ SUCCESSFUL
└─▶ FAILED
status: ACTIVE | INACTIVEA single image version can produce multiple Build records — one per (architecture, chipset, chipsetGeneration). Each build has its own buildState: PENDING → IN_PROGRESS → SUCCESSFUL | FAILED. List with list-microvm-image-builds.
UpdateMicrovmImageVersion switches a version's status between ACTIVE and INACTIVE — RunMicrovm will only resolve ACTIVE versions when no explicit imageVersion is supplied.
MicroVM state machine
PENDING
│
▼
RUNNING ◀──── (auto-resume on ingress, or ResumeMicrovm)
│ ▲
▼ │
SUSPENDING ──▶ SUSPENDED
│
▼ (after suspendedDurationSeconds, or TerminateMicrovm)
TERMINATING ──▶ TERMINATEDTriggers:
RunMicrovm→PENDING→RUNNING.Idle for
maxIdleDurationSecondsof no proxy traffic →SUSPENDING→SUSPENDED. Or callSuspendMicrovm.Ingress traffic on the endpoint with
autoResumeEnabled: true, orResumeMicrovm→RUNNING.SUSPENDEDforsuspendedDurationSeconds→ terminated.Maximum lifetime
maximumDurationInSeconds(cap 28,800 s = 8 hr) reached → terminated.TerminateMicrovmfrom anywhere.
Idle is measured by traffic through the proxy endpoint. If your app does outbound work but receives no inbound traffic, the platform will count it as idle. For background workers, set high maxIdleDurationSeconds or disable auto-suspend by omitting idlePolicy in the request.
Lifecycle hooks
Your application can implement HTTP endpoints that Lambda invokes at lifecycle transitions. Hooks are opt-in per image via the --hooks parameter. You must specify the port your hooks listen on (commonly 9000).
Image build hooks
| Hook | Path | When invoked | Timeout field | Use it for |
|---|---|---|---|---|
/ready | POST /aws/lambda-microvms/runtime/v1/ready | During image build, before snapshot capture | readyTimeoutInSeconds (1–3600) | Confirm app initialized; fail the build if app is broken |
/validate | POST /aws/lambda-microvms/runtime/v1/validate | After build, on a test MicroVM run from the snapshot | validateTimeoutInSeconds (1–3600) | End-to-end smoke test of the snapshot |
Implementing image build hooks is recommended for performance — they ensure your application is fully initialized before the snapshot is captured, resulting in faster runs.
MicroVM hooks
| Hook | Path | When invoked | Timeout field | Use it for |
|---|---|---|---|---|
/run | POST /aws/lambda-microvms/runtime/v1/run | Once, immediately after a MicroVM is run (resumed from snapshot) | runTimeoutInSeconds (1–60) | Create per-VM unique state, fetch secrets, register with discovery. Should be quick — not for long-running work |
/resume | POST /aws/lambda-microvms/runtime/v1/resume | After SUSPENDED → RUNNING | resumeTimeoutInSeconds (1–60) | Re-establish connections, generate new randomness if your application relies on non-CSPRNGs |
/suspend | POST /aws/lambda-microvms/runtime/v1/suspend | Just before RUNNING → SUSPENDED | suspendTimeoutInSeconds (1–60) | Return 200 only when the app is ready to be suspended. Customer decides the strategy: wait for in-flight work to drain within the timeout, or return immediately |
/terminate | POST /aws/lambda-microvms/runtime/v1/terminate | Just before termination | terminateTimeoutInSeconds (1–60) | Flush logs, persist state, deregister |
If you use microVM hooks, you must implement the
/readymicroVM image hook. This ensures your application has booted and can receive hook events.Always set explicit timeout values in
--hookswhen creating the image — especially for/ready(init) and/run//resume(any per-VM init work).
Configuring hooks (image creation)
--hooks '{
"port": 9000,
"microvmImageHooks": {
"ready": "ENABLED",
"readyTimeoutInSeconds": 60,
"validate": "ENABLED",
"validateTimeoutInSeconds": 10
},
"microvmHooks": {
"run": "ENABLED",
"runTimeoutInSeconds": 2,
"resume": "ENABLED",
"resumeTimeoutInSeconds": 2,
"suspend": "ENABLED",
"suspendTimeoutInSeconds": 5,
"terminate": "ENABLED",
"terminateTimeoutInSeconds": 5
}
}'A hook left at its default DISABLED is not called even if the application implements the path.
Hook contract
Return HTTP 200 when the hook has completed successfully. For
/readyand/validate, return 503 if the application needs more time — the platform will keep retrying until the configured timeout elapses. Returning 503 quickly is preferred over blocking the request until ready: a blocked call holds the connection open and can consume the entire timeout window in one attempt instead of letting the platform poll.During image build, a
/readyfailure (non-200/503 or timeout) fails the build.At runtime, a hook failure may cause
RunMicrovmto fail or transition the MicroVM throughTERMINATINGwithstateReasonset.
The
runHookPayloadyou pass toRunMicrovmis delivered as the request body of/run.
Sequence: run + ingress + idle + resume + terminate
Lambda Your app
│ │
RunMicrovm ───────────▶│ │
│ resume snapshot │
│ POST /run (runHookPayload)│
│────────────────────────────▶│ 200
│ │
client ──── HTTPS ingress ──────────▶│ (request handled)
│ ... no traffic for │
│ maxIdleDurationSeconds ... │
│ POST /suspend │
│────────────────────────────▶│ 200
│ suspend (snapshot RAM+disk)
│ │
client ──── HTTPS ingress ──────────▶│ (auto-resume if enabled)
│ resume │
│ POST /resume │
│────────────────────────────▶│ 200
│ ... eventually ... │
TerminateMicrovm ─────▶│ POST /terminate │
│────────────────────────────▶│ 200
│ stop │Idle policy fields
The idlePolicy block itself is optional on RunMicrovm — omit it to disable idle-based auto-suspend entirely. If you supply the block, all three fields below are required:
| Field | Range | Notes |
|---|---|---|
maxIdleDurationSeconds | ≥60 | Required if idlePolicy is supplied. Idle threshold from last proxy traffic. |
suspendedDurationSeconds | ≥0 | Required if idlePolicy is supplied. Time-to-terminate while suspended. 0 means "terminate immediately on suspend." |
autoResumeEnabled | bool | Required if idlePolicy is supplied. If true, proxy resumes the VM transparently when traffic arrives at its endpoint. |
maximumDurationInSeconds is not an idlePolicy field — it is a separate top-level RunMicrovm flag that sets a hard wall-clock lifetime regardless of activity.
Hook implementation tips
Bind to
0.0.0.0on the configuredport. Lambda calls hooks over the guest's network namespace; localhost-only listeners are unreachable.Run hooks in a separate thread / event loop from your application server.
/suspendshould still answer 200 even if your main worker pool is busy.Keep
/runand/resumefast. These hooks are notification mechanisms. If your application needs to run long-running workflows (> 60s) in response, do so asynchronously.Don't use
/runfor long-running init. That work belongs at image build time so it's captured in the snapshot. Avoid generating random data at build time — if unique random state is needed, invalidate and re-generate using a CSPRNG on/run.Make hooks idempotent. Lambda may retry
/suspendor/terminateunder failure conditions.
Where to go next
Per-VM uniqueness (entropy, secrets, env vars vs.
runHookPayload):snapshots-and-uniqueness.mdHook-related failure modes:
troubleshooting.md
Requirements and compatibility
Written for: Claude Code
Works with: Claude Code, Claude apps, OpenAI Codex, GitHub Copilot, Cursor, Gemini CLI, Kiro, OpenCode, Goose, Amp, Roo Code, JetBrains Junie, Factory Droid, Devin (ex-Windsurf), Mistral Vibe, OpenHands, Letta
“Works with” means the tool reads the open Agent Skills format; a skill written for one tool may use features others lack.
Needs: Claude Code frontmatter, Needs an MCP server, Needs a command-line tool
Security
What our scanner noticed· Low risk
- Instructions that use the network
A static scan is not a guarantee. Skills are third-party content: review a skill before you let an agent use it.
Attribution and licence
- Published by
- AWS Labs
- Publisher
- AWS Labs (Official)
- Source
- awslabs/agent-plugins · plugins/aws-serverless/skills/aws-lambda-microvms · commit fbefb37
- Licence
- Apache License 2.0 (redistribution allowed)
- LICENSE (added by AutoGineer from LICENSE)
- NOTICE (added by AutoGineer from NOTICE)
- ATTRIBUTION.md (written by AutoGineer)
- Synced
AutoGineer is not affiliated with or endorsed by AWS Labs.
Download ZIP
The ZIP holds the skill’s files, its licence files and an ATTRIBUTION.md. Download aws-lambda-microvms.zip