Loading...
Loading...
Builds, runs, debugs, and operates applications on AWS Lambda MicroVMs — Firecracker-isolated, snapshot-resumable serverless compute environments running inside a container with up to 8 hr lifetimes. Applicable when workloads need strong isolation between tenants, isolated serverless compute, sandbox compute, or secure multi-tenant execution. Also suited for AI/agent code-execution sandboxes, interactive code playgrounds and notebooks (Jupyter, REPLs, dev environments running user-supplied code), reinforcement-learning environments, multi-tenant CI executors and build runners, sessionful game or simulation servers, or isolated security scanners. Also applicable when the workload needs long-lived sessions, a real port-listening server (gRPC, WebSocket, custom TCP protocols), state preserved across periods of inactivity (suspend/resume), container-level access (FUSE, eBPF, custom syscalls), or session-affine routing.
npx skill4agent add aws/agent-toolkit-for-aws aws-lambda-microvmsThe AWS MCP server is recommended for sandboxed execution and audit logging.
MicrovmImage{S3 zip with Dockerfile} + baseImageArnBuildMicrovmRunMicrovmbuildRoleArnexecutionRoleArnRunMicrovmListMicrovmImagesDockerfile9000/run/resume/suspend/terminate/ready/validate/ready/validateexecutionRoleArnidlePolicyrunHookPayloadendpointmicrovmIdallowedPortsX-aws-proxy-auth: <token>idlePolicymaxIdleDurationSecondssuspendedDurationSecondsautoResumeEnabled# 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-...references/getting-started.md--hooks--hooksmicrovmImageHooksRecommendation: Implement the image build hooks (and/ready) for best performance. They enable the platform to capture a complete snapshot and prefetch the portions accessed at run time./validate
| Hook | Purpose | Timeout range |
|---|---|---|
| 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) |
| 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? 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./readyWhy implement? It lets the platform verify the snapshot is correct, and also samples which portions of the snapshot are accessed during/validate. This allows the platform to prefetch those portions on future launches, reducing cold-start times.RunMicrovm
microvmHooks| Hook | Purpose | Timeout range |
|---|---|---|
| Fires once after run from snapshot | 1–60s (default 1s) |
| Fires after SUSPENDED → RUNNING | 1–60s (default 1s) |
| Fires before RUNNING → SUSPENDED | 1–60s (default 1s) |
| Fires before termination | 1–60s (default 1s) |
references/getting-started.md| 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-os-capabilities '["ALL"]'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_INGRESSaws 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 \
--ingress-network-connectors '["arn:aws:lambda:<region>:aws:network-connector:aws-network-connector:SHELL_INGRESS"]' \
--idle-policy '{"maxIdleDurationSeconds":900,"suspendedDurationSeconds":300,"autoResumeEnabled":true}'delete-microvm-image-versionSuspendMicrovm/run/resume/suspend/terminatereferences/getting-started.mdreferences/lifecycle-model.mdreferences/snapshots-and-uniqueness.mdreferences/networking.mdX-aws-proxy-*references/iam-and-security.mdlambda:PassNetworkConnectorreferences/troubleshooting.md8080X-aws-proxy-portlambda-microvms.port.<n>aws:SourceAccountaws:SourceArnreferences/iam-and-security.mdreferences/snapshots-and-uniqueness.md