AWS Lambda Microvms
AWSOfficialPublished by AWS
- 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 leverages Firecracker VM isolation combined with container-like efficiency. This skill enables developers to run applications in secure, isolated environments that support long-lived sessions up to 8 hours, state preservation via suspend/resume, and direct container-level access. It is designed for workloads requiring strong tenant isolation, such as AI code-execution sandboxes, interactive notebooks, multi-tenant CI runners, and sessionful simulation servers.
What it does
- Packages applications into Firecracker-isolated MicroVMs using Dockerfiles.
- Supports snapshot-based booting to skip application initialization at runtime.
- Provides lifecycle hooks for managing application state during run, resume, suspend, and termination.
- Enables secure, token-authenticated ingress for HTTP, gRPC, and WebSocket traffic.
- Allows for optional shell access for debugging and agent-driven workflows.
- Supports advanced OS capabilities like FUSE, eBPF, and nested containers.
When to use it
- When you need strong tenant isolation for secure multi-tenant execution.
- When your application requires long-lived sessions or state preservation across inactivity.
- When building interactive code playgrounds, notebooks, or AI agent sandboxes.
- When you need to run custom network protocols like gRPC or WebSockets in a serverless environment.
- When you require container-level access to system resources like eBPF or FUSE.
Advantages
- Strong security isolation via Firecracker microVMs.
- Fast startup times through memory and disk snapshots.
- Flexible lifecycle management with suspend and resume capabilities.
- Support for long-running sessions up to 8 hours.
- Consistent local development experience using standard Dockerfiles.
Usage examples
- “How do I create a new MicroVM image from my Dockerfile?”
- The agent provides the 'aws lambda-microvms create-microvm-image' command, specifying the S3 artifact location, build role, and base image ARN.
- “How can I securely connect to my running MicroVM?”
- The agent explains how to use 'aws lambda-microvms create-microvm-auth-token' to generate a short-lived token for header-based authentication.
- “How do I implement lifecycle hooks for my application?”
- The agent provides a code example for implementing HTTP endpoints (e.g., /ready, /run, /suspend) that the platform calls to manage the MicroVM state.
Install
Download the skill as a ZIP:
https://mp-staging.autogineer.com/agent-skills/aws/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
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 Lambda Event Functions when
The workload fits in 15 minutes.
Per-function isolation is sufficient; if ordinary event/request handlers need execution environments dedicated to one invoker or tenant, use Event Functions on On-Demand with tenant isolation mode. Do not assume Lambda creates a fresh Firecracker VM or execution environment for every invocation.
No session state needs to remain in memory, on disk, or in running processes between interactions.
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).
ARN partitions
Every ARN in this skill is written arn:<partition>:.... Set the partition from the target region. Do not default to arn:aws:, because an ARN with the wrong partition is rejected.
Only the partition segment changes. The aws account field in managed base image ARNs (arn:<partition>:lambda:<region>:aws:microvm-image:...) and default network connector ARNs stays aws. Where possible, copy ARNs from API output (list-managed-microvm-images, create-microvm-image, get-microvm-image) instead of building them by hand.
MicroVM endpoint domains also differ in China. Endpoints are <microvm-id>.lambda-microvm.<region>.on.aws in commercial regions and <microvm-id>.lambda-microvm.<region>.on.amazonwebservices.com.cn in China regions. Use the endpoint value returned by run-microvm or get-microvm instead of building the hostname. The VPC endpoint service name, com.amazonaws.<region>.lambda-microvm, is the same in every partition.
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:<partition>:lambda:<region>:aws:microvm-image:al2023-1 \
--build-role-arn arn:<partition>:iam::<acct>:role/MicroVMBuildRole \
--code-artifact '{"uri":"s3://<bucket>/<key>.zip"}'
# Run a MicroVM (returns endpoint + microvmId). --image-identifier takes the
# image ARN and --image-version is the full major.minor string.
aws lambda-microvms run-microvm \
--image-identifier arn:<partition>:lambda:<region>:<acct>:microvm-image:my-image \
--image-version 1.0 \
--execution-role-arn arn:<partition>: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:<partition>:lambda:<region>:aws:microvm-image:al2023-1 \
--build-role-arn arn:<partition>: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:<partition>:lambda:<region>:<acct>:microvm-image:my-image \
--execution-role-arn arn:<partition>:iam::<acct>:role/MicroVMExecutionRole \
--ingress-network-connectors '["arn:<partition>: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 AutoGineer928 B
- LICENSELicence file added by AutoGineer9.9 KiB
- NOTICELicence file added by AutoGineer67 B
- SKILL.md15.7 KiB
- references/getting-started.md9.0 KiB
- references/iam-and-security.md6.0 KiB
- references/lifecycle-model.md9.7 KiB
- references/networking.md9.2 KiB
- references/snapshots-and-uniqueness.md6.6 KiB
- references/troubleshooting.md8.5 KiB
references/snapshots-and-uniqueness.md
Snapshots and uniqueness
The single most important MicroVM-specific concept: every MicroVM launched from an image starts from the same snapshot. State generated during image build is replicated across all instances.
What gets snapshotted
During image build, after your Dockerfile runs and your CMD/ENTRYPOINT starts the application, Lambda waits for /ready (if enabled), then captures the full OS snapshot:
Disk snapshot — the rootfs after layer extraction + any files written during init.
Memory snapshot — RAM image including kernel state, OS state, and every running process started by the entrypoint (including background daemons).
When you RunMicrovm, Lambda restores both, and your processes are already running. No python app.py re-execution. No connection-pool warmup. No JIT cold-start.
This is what makes fast runs possible — but it also means anything in memory or on disk at snapshot time is shared. Snapshots are not updated by the service. It's the customer's responsibility to update them.
The uniqueness problem
If your build-phase code does any of these, it ends up in the snapshot and is identical across every MicroVM:
Generates UUIDs / instance IDs.
Seeds a PRNG with the current time.
Fetches a secret or token.
Reads
/dev/urandomonce and caches the bytes.Establishes a TCP connection (the connection itself won't survive snapshot, but state derived from it will).
Fixes, in order of preference
Don't generate it at build time. Generate at first use, after run.
Generate it in
/run. This hook fires once after run (post-snapshot resume) and is the canonical place to create per-VM unique state. SetmicrovmHooks.run: "ENABLED"in--hooks.Read fresh entropy from a CSPRNG. These are wired to the kernel RNG which Firecracker re-seeds across snapshot resume — see the language table below.
Inject per-VM data via
runHookPayload. The opaque blob you pass toRunMicrovmis delivered as the request body of/run, so you can include tenant IDs, signed URLs, parameter-store paths, etc.
CSPRNGs that are safe across snapshot resume
| Language | Use | Don't use |
|---|---|---|
| Java | java.security.SecureRandom | java.util.Random, Math.random() seeded once |
| Python | secrets, random.SystemRandom | random.random() with default seed |
| .NET | System.Security.Cryptography.RandomNumberGenerator | System.Random instance reused across snapshot |
| Node.js | crypto.randomBytes, crypto.randomUUID | Math.random() |
| Go | crypto/rand | math/rand |
| Rust | rand::rngs::OsRng | rand::thread_rng() if seeded once before snapshot |
| C/C++ | getrandom(2), /dev/urandom per-call | rand(), srand(time(NULL)) once |
The Lambda base ECR image (public.ecr.aws/lambda/microvms:al2023-minimal) ships an OpenSSL build that automatically re-seeds entropy on snapshot resume. If you bring your own base image, your OpenSSL version will not do this by default — use the Lambda base image or ensure your application reads fresh entropy per-call. Reading /dev/urandom per-call is safe — the kernel RNG reseeds on resume.
Connections and snapshot resume
TCP connections opened in the entrypoint (e.g. an SDK client warming up) are captured in memory but not in any meaningful network sense — the underlying socket isn't valid after resume. All outbound (non-local) connections are killed on run and resume. Most AWS SDKs handle this transparently (they retry on EBADF/ECONNRESET). For other clients, ensure your connection libraries have timeouts and retries configured to re-establish connections automatically.
Configuration data: env vars vs. run payload vs. execution-role secrets
You have three places to inject configuration:
| Where | Set at | Same for all VMs? | Visible to | Use for |
|---|---|---|---|---|
Build env vars (--environment-variables) | Image creation | Yes — burnt into the snapshot | Container env at build time and after resume | Static, non-sensitive: log level, app port, feature toggles |
runHookPayload | RunMicrovm | No — per-VM | Body of the /run POST | Per-VM: tenant ID, session ID, signed URLs, references to secrets |
| Execution role + AWS SDK | At run | No — assumed credentials | IMDSv2 in the guest | Real secrets — fetch from Secrets Manager / SSM Parameter Store at runtime |
Inspecting snapshot sizes
Each successful build records snapshot sizes. Use these to track image bloat over time:
BUILD_ID=$(aws lambda-microvms list-microvm-image-builds \
--image-identifier arn:<partition>:lambda:<region>:<account>:microvm-image:my-image \
--image-version 1.0 \
--query 'items[0].buildId' --output text)
aws lambda-microvms get-microvm-image-build \
--image-identifier arn:<partition>:lambda:<region>:<account>:microvm-image:my-image \
--image-version 1.0 \
--build-id "$BUILD_ID"Fields of interest (nested under snapshotBuild):
snapshotBuild.memorySnapshotSizeInBytes— RAM image. Dominated by your application's RSS plus kernel pages dirtied during boot. Big numbers usually mean the app over-eagerly preallocates buffers / loads big models in memory.snapshotBuild.codeInstallSizeInBytes— size of the code artifact after it's compiled from the Dockerfile and installed in the filesystem. Dominated by the container image.snapshotBuild.diskSnapshotSizeInBytes— bytes written by the OS or application during boot (does not include codeInstallSizeInBytes).
Heuristics:
Resume time scales with snapshot size accessed, roughly 1 s per 500 MB. Trim aggressively.
A bloated
diskSnapshot→ audit the Dockerfile (multi-stage builds,--no-install-recommends,dnf clean all, removepipcaches).A bloated
memorySnapshot→ check for over-eager warmup (loading every model variant at boot, opening millions of fds, etc.).
Disk-vs-memory restore behavior
Memory is eagerly restored on run/resume, while block device (disk) content is demand-paged. This means a larger memory snapshot directly increases the time it takes for a snapshot to fully restore. Keep memory snapshots as small as possible for fast runs — avoid over-eager preallocation of buffers or loading large models entirely into RAM at build time.
If your app needs unique state at startup
Common patterns:
Listen for
/runand receive themicrovmIdviarunHookPayload.microvmIdis automatically injected in the request. Block your app's request handlers until/runreturns.Pass it in
runHookPayload: the caller (your control plane) generates per-VM state and ships it in theRunMicrovmcall.
Requirements and compatibility
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: 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
- Publisher
- AWS (Official)
- Source
- aws/agent-toolkit-for-aws · skills/specialized-skills/serverless-skills/aws-lambda-microvms · commit 0a218f8
- 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.
Download ZIP
The ZIP holds the skill’s files, its licence files and an ATTRIBUTION.md. Download aws-lambda-microvms.zip