npx skills add ...
npx skills add aws/agent-toolkit-for-aws --skill aws-lambda-managed-instances
Evaluates, configures, and migrates workloads to AWS Lambda Managed Instances (LMI). Runs Lambda functions on EC2 instances in the user's account while AWS manages provisioning, patching, scaling, routing, and load balancing. Triggers when queries mention Lambda Managed Instances, LMI, capacity providers, multi-concurrent execution environments, EC2-backed Lambda, persistent Lambda instances, PerExecutionEnvironmentMaxConcurrency, CapacityProviderConfig, cold start elimination via dedicated instances, migrating standard Lambda to managed instances, or cost comparison between standard Lambda and LMI with Savings Plans or Reserved Instances. Also covers long-running and asynchronous workloads and the 90-minute (5400s) function timeout for asynchronous and event-source-mapping (SQS, Kinesis, DynamoDB Streams / ESM) invocations, including how to raise the function timeout up to 90 minutes / 5400s and the related duration limits.
npx skills add aws/agent-toolkit-for-aws --skill aws-lambda-managed-instances
Runs Lambda functions on EC2 instances in the user's account while AWS manages provisioning, patching, scaling, routing, and load balancing. Combines Lambda's developer experience with EC2's pricing and hardware options.
Works best with the AWS MCP server for sandboxed CLI execution and audit logging. All guidance also works with standard AWS CLI or SAM CLI.
Note: Confirm regional availability, quotas, and instance type offerings against current AWS documentation before production deployment.
| Signal | LMI is a strong fit | Standard Lambda is better |
|---|---|---|
| Traffic | Steady, predictable, 50M+ req/mo | Bursty, unpredictable, long periods of no traffic |
| Duration | Long-running asynchronous/ESM jobs that exceed 15 min (up to 90 min on LMI): ETL/data processing, media transcoding, ML inference, financial calc, web scraping | Short invocations; synchronous work needing >15 min (not supported on any Lambda) |
| Cost | Duration-heavy spend at scale | Low or sporadic invocations |
| Cold starts | Unacceptable (LMI eliminates for provisioned capacity) | Tolerable |
| Compute | Latest CPUs, specific families, high network bandwidth, GPU requirements | Standard Lambda memory/CPU sufficient |
| Isolation | Dedicated EC2 instances in your account, full VPC control | Shared Firecracker micro-VMs acceptable |
| Scale-to-zero | Does not scale to zero but can create custom schedules with AWS provided solutions | Required (pay nothing when idle) |
| Code readiness | Thread-safe (Node.js/Java/.NET) or any Python code | Non-thread-safe code, expensive to change |
Read ONLY the single reference file that matches the user's task. Do not preload multiple references.
| User need | Action |
|---|---|
| Cost comparison, pricing analysis, Savings Plans, Reserved Instances | Read cost-comparison.md |
| Instance types, memory sizing, vCPU ratios, scaling tuning, capacity provider config | Read configuration-guide.md |
| Thread safety, concurrency model, code review checklist, multi-concurrency readiness | Read thread-safety.md |
| Before/after code examples, runtime-specific migration, connection pooling | Read migration-patterns.md |
| IAM roles, VPC setup, CLI commands, SAM template, CDK example | Read infrastructure-setup.md |
| Errors, throttling, debugging, stuck deployments | Read troubleshooting.md |
Troubleshooting quick facts (always mention when diagnosing issues):
Gather these signals before recommending:
/tmp paths? Per-invocation DB connections?Long-running asynchronous/ESM jobs that exceed 15 min are a positive fit — LMI supports a function timeout up to 90 min (5400s) for asynchronous and event-source-mapping invocations (ETL/data processing, media transcoding, ML inference, financial calc, web scraping). Duration is the key differentiator here, not just cost.
When recommending LMI, ALWAYS mention: minimum 3 execution environments for AZ resiliency (cannot go below 3 in production).
REQUIRED: Present a cost comparison before recommending LMI.
Rule of thumb: LMI becomes cost-competitive at 50-100M+ req/month with steady traffic. Use the LMI Pricing Calculator for accurate comparisons.
Architectures: [arm64] in the function configuration to match.Timeout field (CLI update-function-configuration --timeout 5400, SAM/CFN Timeout: 5400, or console). Uses the existing Timeout field — no separate API, property, tag, or code change is required. Applies to asynchronous and ESM invocations only; synchronous and On-Demand invocations stay capped at 15 min (even if Timeout is higher; GetFunctionConfiguration still reports the configured value). The Init phase is still capped at 15 min. Durable Functions: each step can run up to 90 min; a multi-step workflow up to 1 year.Review code for concurrency safety. LMI runs multiple invocations concurrently per execution environment:
/tmp conflicts and memory sizing.ReportBatchItemFailures) and tune the max batching window and parallelization factor — otherwise one failed record retries the whole batch, re-running up to ~80 min of already-completed work.| Resource | Limit |
|---|---|
| Memory | 2 GB min, 32 GB max |
| Asynchronous/ESM invoke timeout | 90 min (5400s), via the existing Timeout field |
| Sync + On-Demand invoke timeout | 15 min |
| Init phase | 15 min |
| ESM sources capped at 15 min | Amazon MQ, Amazon DocumentDB (SQS/Kinesis/DynamoDB Streams get 90 min) |
| Execution environments | 3 minimum (MinExecutionEnvironments, AZ resiliency) |
| Instance lifespan | 14 days (auto-replaced) |
| Concurrency/vCPU | 64 (Node.js), 32 (Java/.NET), 16 (Python) |
| Runtimes | Node.js 22+, Java 21+, .NET 8+, Python 3.13+, Rust (provided.al2023) |
| Instance families | C, M, R (.large and up) |
| Scaling | Burst headroom equals unused capacity from TargetResourceUtilization; new instances launch within minutes |
aws:SourceAccount and aws:SourceArn conditions to trust policies to prevent confused deputy attacks.| File | Content |
|---|---|
| cost-comparison.md | Pricing analysis, break-even calculations, Savings Plans/RI impact |
| configuration-guide.md | Instance selection, memory ratios, scaling tuning, capacity provider config |
| thread-safety.md | Concurrency model per runtime, code review checklist, Powertools compatibility |
| migration-patterns.md | Before/after code by runtime, connection pooling, gradual cutover |
| infrastructure-setup.md | IAM roles, VPC setup, SAM templates, CLI commands |
| troubleshooting.md | Common errors, throttling, debugging, stuck deployments |