AWS Builder Center
Beyond Stateless Lambda: A Deep Dive into AWS Lambda MicroVMs for Isolated AI Sandboxes

Beyond Stateless Lambda: A Deep Dive into AWS Lambda MicroVMs for Isolated AI Sandboxes

Explore how isolated, stateful serverless environments support AI agents, cloud IDEs, and other session-based workloads. This guide explains the lifecycle, control-plane responsibilities, pricing model, operational trade-offs, and when to choose them over Lambda Functions or always-on compute.

What happens when your workload needs Lambda’s serverless experience, but the execution environment itself must survive between interactions?

The workload that does not fit inside a function

An AI coding agent installs 60 packages, edits 14 files, starts a development server, runs a test suite, and then waits two minutes for its next instruction.
A Lambda Function can execute individual commands, but a function invocation does not naturally represent the evolving workspace. An always-on EC2 instance can preserve that workspace. Now you are maintaining and paying for a server even while the agent waits for an LLM response.
There is an increasingly important gap between those options: an isolated environment that belongs to one user or job, preserves its state, and can stop consuming compute while it waits.
AWS introduced Lambda MicroVMs on June 22, 2026  for this category of workload. Built on Firecracker virtualization, the service provides VM-level isolation, state preservation, and a dedicated HTTPS endpoint for each MicroVM. AWS positions it for executing user- or AI-generated code in interactive coding environments, analytics platforms, coding assistants, vulnerability scanners, and other session-oriented systems.
MicroVMs do not replace Lambda Functions. They give us a different primitive for workloads where a request handler is too temporary and an always-on server is too permanent.

The missing middle: a pop-up workshop

Here is the analogy I keep coming back to:
  • Lambda Functions are a courier counter. Work arrives, gets processed, and leaves. AWS owns the execution-environment lifecycle.
  • EC2, ECS, or other always-on compute are a leased workshop. You keep the environment available and take responsibility for capacity and idle time.
  • Lambda MicroVMs are a secure pop-up workshop. Create a reusable image, start an isolated workspace for a user or job, suspend it when it becomes idle, and resume it later with the useful state preserved.
A MicroVM image captures a pre-initialized application environment. When a running MicroVM is suspended, AWS preserves its memory and disk state. According to AWS Lambda MicroVMs pricing , compute charges stop during suspension. Snapshot reads, writes, and storage remain billable.
An AI Coding Session from Launch to Resume
The application manages the session while AWS provides the isolated runtime, preserves memory and disk during suspension, and restores the environment when work resumes.
The documented default baseline is 2 GB memory and 1 vCPU. A MicroVM can vertically scale its memory and vCPU up to four times the configured baseline. The AWS Lambda pricing examples  include a 2 GB / 1 vCPU baseline scaling to 8 GB / 4 vCPU, and an 8 GB / 4 vCPU baseline scaling to 32 GB / 16 vCPU.
Consider a coding environment that spends most of its time editing files but occasionally compiles a large project. You can provision for typical activity, while Lambda supplies additional capacity during the resource-intensive phase and bills it only while it is consumed.

Following an AI coding session end to end

Rather than treating the lifecycle as a list of API operations, let us follow one session.
1
2
3
4
5
6
7
8
9
10
Developer starts an agent session
→ Control plane selects a pre-built Node.js MicroVM image
→ A dedicated MicroVM launches for that developer
→ The agent installs dependencies, edits files, and runs tests
→ The agent waits for the next LLM response
→ An idle policy suspends the MicroVM and preserves its state
→ The next tool request resumes the same environment
→ The agent continues with its files and working state intact
→ Important artifacts are persisted outside the MicroVM
→ The control plane terminates the environment when the session ends

1. Build the reusable starting point

The AWS Lambda MicroVMs developer guide  describes the image workflow. You package application code and a Dockerfile into an archive in Amazon S3. Lambda executes the Dockerfile, starts the application, and captures a snapshot of the initialized environment as a MicroVM image.
An AI coding platform might maintain separate images with pre-installed toolchains for Node.js, Python, Java, Rust, or Go. Think of an image as a reusable template, not as the developer’s workspace.

2. Give the session its own environment

When the developer starts a session, the control plane launches a MicroVM from the selected image. The running environment receives a dedicated HTTPS endpoint. The developer guide  documents configurable inbound ports and support for HTTP/2, gRPC, and WebSockets.
The application records the relationship:
1
user/session ID → MicroVM ID → endpoint → lifecycle state
This mapping turns an infrastructure resource into a user session.

3. Preserve useful state during the pauses

The agent installs packages, writes files, and starts processes inside its environment. When it waits for model inference or user input, an automatic or programmatic policy can suspend the MicroVM. The Lambda MicroVMs lifecycle documentation  confirms that the environment resumes with memory and disk state intact when work returns.
AWS supports suspend/resume execution for up to eight hours . Anything that must outlive that boundary belongs in durable storage outside the MicroVM.

The hidden trade-off: you still own the control plane

This is the part I would not skip in an architecture review:
Lambda MicroVMs provide serverless virtualized infrastructure. They do not make the surrounding session architecture disappear.
AWS manages Firecracker hosts, image restoration, vertical scaling, and the underlying execution infrastructure. Your application still owns the decisions that make a fleet behave like a product.
Control-plane responsibilityThe question your architecture must answer
Session mappingWhich MicroVM belongs to this user, tenant, or job?
Lifecycle policyWhen should it launch, suspend, resume, and terminate?
Access controlWho may connect to the dedicated endpoint?
Durable stateWhat must survive beyond the MicroVM lifecycle?
Concurrency and quotasHow many environments may one tenant create?
Failure recoveryWhat happens if launch, resume, or persistence fails?
ObservabilityCan operators correlate a user session with lifecycle events, errors, and cost?
The Application Control Plane Around Lambda MicroVMs
Architecture diagram showing clients connecting through an application control plane to AWS-managed MicroVMs, suspended state, durable storage, VPC resources, and operational signals
Networking requires the same deliberate thinking. Lambda MicroVMs support public internet access and VPC access through Lambda Network Connectors, as described in the Lambda MicroVMs networking guide . IAM permissions answer which AWS actions the workload may perform. Network configuration answers which destinations it can reach. Code supplied by users or AI needs both boundaries to be intentional.
MicroVMs remove the need to build and operate the virtualization fleet. Lifecycle design remains your responsibility. That is part of their power, but it is also part of their cost.

Pricing: pay for activity, preserve the state

The AWS Lambda pricing page  describes three Lambda MicroVM pricing components:
  1. Compute: billed per second while the MicroVM runs.
  2. Snapshots: data read on launch or resume, data written on suspend, and snapshot/image storage.
  3. Data transfer: charged at standard AWS data-transfer rates.
For US East (N. Virginia), AWS uses these Graviton (ARM) rates in its published examples:
ResourcePublished rate
vCPU$0.0000276944 per vCPU-second
Memory$0.0000036667 per GB-second
Snapshot write$0.0038 per GB
Snapshot read$0.00155 per GB
Snapshot and image storage$0.08 per GB-month
Pricing note: MicroVM image storage has a one-week minimum retention period. Prices are regional and time-sensitive, so verify them on the current AWS Lambda pricing page  before making an architectural decision.

What the AWS coding-assistant example tells us

In its coding-assistant pricing example , AWS models 100 developers using 2 GB / 1 vCPU baseline environments. Each developer is active for 2.5 hours over an eight-hour workday and goes through six suspend/resume cycles per day. Across 20 working days, AWS calculates:
Charge categoryAWS example total
Compute$1,103.38
Snapshot reads and writes$134.60
Snapshot and image storage$3.24
Total$1,241.22
Per developer (per month)$12.41
The $12.41 figure is specific to that scenario. The way the bill divides is more useful:
  • Active duration and consumed capacity dominate compute cost.
  • Suspend/resume frequency and state size drive snapshot-operation cost.
  • Image count, image size, and retained state drive storage cost.
  • Region, data transfer, and connected services complete the real bill.
Snapshot charges may look trivial for one environment. Multiply them across thousands of frequently suspended environments and they deserve first-class capacity and cost modelling.

When I would and would not use MicroVMs

Choosing the Right Compute Model for the Workload
Start with Lambda Functions for short event-driven work, evaluate Lambda MicroVMs when isolated state must survive between interactions, and consider always-on compute for continuous or specialized workloads.
I would evaluate Lambda MicroVMs when the environment itself is part of the application’s state:
  • an AI agent needs the same files and installed packages across tool calls;
  • a cloud IDE needs a private workspace per developer;
  • an analytics session needs an isolated, interactive runtime;
  • a build or security platform executes tenant-supplied code;
  • suspend/resume meaningfully reduces idle compute without discarding the session.
I would not choose MicroVMs merely because a task exceeds a Lambda Function’s invocation duration. If the workload does not need per-session isolation, preserved execution state, or explicit lifecycle control, Lambda Functions, ECS, Fargate, EC2, or another AWS compute option may remain simpler.
I would also look elsewhere when the service’s current resource model, lifecycle window, architecture, Region availability, or networking model does not fit the workload. Being serverless is not enough reason to force a workload into the wrong primitive.
My decision test is straightforward:
If losing the execution environment between two user interactions breaks the experience, Lambda MicroVMs deserve evaluation.

Operational guardrails

Before shipping, I would keep these points in the design review:
  • Treat images as templates, not tenant environments. Do not bake runtime credentials, unique values, or user-specific state into an image.
  • Persist beyond the lifecycle boundary. Store source code, outputs, checkpoints, and audit data externally when they must survive beyond eight hours.
  • Re-establish external connections after restoration. Network connections and expiring credentials are runtime concerns. Do not assume a captured connection remains usable after resume.
  • Separate endpoint reachability from authorization. A dedicated URL is not a complete tenant-access model.
  • Define failure behaviour. Decide what the user sees when launch or resume is delayed, persistence fails, or the environment reaches its lifetime limit.
  • Put quotas around tenants. Prevent accidental or malicious environment creation from becoming an unbounded cost or capacity event.
  • Price the fleet, not the demo. Include active capacity, snapshot churn, storage, data transfer, and connected services.
  • Verify current availability. AWS launched Lambda MicroVMs in five Regions  and may expand availability. Confirm the current Region list and service quotas through the AWS Lambda MicroVMs documentation  before implementation.

Conclusion

Lambda Functions remain the cleanest answer for short, event-driven handlers. Always-on compute remains the natural answer for continuously available services. Lambda MicroVMs fill the space between them. They provide isolated, stateful, session-oriented environments without requiring you to operate the virtualization layer.
For AI sandboxes, cloud IDEs, analytics environments, and multi-tenant build systems, that is a meaningful new primitive. The value does not come from Firecracker alone. It comes from pairing managed isolation with a thoughtfully designed control plane, durable-state strategy, and lifecycle policy.
The shift is simple. Stop treating every unit of work as a fresh invocation or a permanently running server. Treat the environment as a managed session. Launch it when work begins, preserve it when work pauses, and terminate it when the session is genuinely complete.
See you next time. Happy building!

Sources and further reading

Any opinions in this article are those of the individual author and may not reflect the opinions of AWS.
Enjoyed reading this content? Let the author know!

Your likes, comments, shares, and saves help creators reach more builders.

Loading recommendations

Loading article