$npx -y skills add awslabs/agent-plugins --skill aws-lambda-managed-instancesEvaluate, configure, and migrate workloads to AWS Lambda Managed Instances (LMI). Triggers on: Lambda Managed Instances, LMI, capacity provider, multi-concurrency Lambda, dedicated instance Lambda, EC2-backed Lambda, cold start elimination, Graviton Lambda, instance type for Lamb
| 1 | # AWS Lambda Managed Instances (LMI) |
| 2 | |
| 3 | Run Lambda functions on current-generation EC2 instances in your account while AWS manages provisioning, patching, scaling, routing, and load balancing. Combines Lambda's developer experience with EC2's pricing and hardware options. |
| 4 | |
| 5 | For standard Lambda development, see [aws-lambda skill](../aws-lambda/). For SAM/CDK deployment, see [aws-serverless-deployment skill](../aws-serverless-deployment/). |
| 6 | |
| 7 | ## When to Load Reference Files |
| 8 | |
| 9 | - **Cost comparison**, **pricing analysis**, **Lambda vs LMI cost**, **Savings Plans**, or **Reserved Instances** -> see [references/cost-comparison.md](references/cost-comparison.md) |
| 10 | - **Instance types**, **memory sizing**, **vCPU ratios**, **scaling tuning**, **scheduled scaling**, or **capacity provider config** -> see [references/configuration-guide.md](references/configuration-guide.md) |
| 11 | - **Thread safety**, **concurrency model**, **code review checklist**, **Powertools compatibility**, or **multi-concurrency readiness** -> see [references/thread-safety.md](references/thread-safety.md) |
| 12 | - **Before/after code examples**, **runtime-specific migration** (Node.js, Python, Java, .NET), or **connection pooling** -> see [references/migration-patterns.md](references/migration-patterns.md) |
| 13 | - **IAM roles**, **VPC setup**, **CLI commands**, **SAM template**, **CDK example**, or **scheduled scaling setup (EventBridge Scheduler)** -> see [references/infrastructure-setup.md](references/infrastructure-setup.md) and [scripts/setup-lmi.sh](scripts/setup-lmi.sh) |
| 14 | - **Errors**, **throttling**, **debugging**, **stuck deployments**, **tuning configuration**, or **adjusting after deployment** -> see [references/troubleshooting.md](references/troubleshooting.md) |
| 15 | |
| 16 | ## Quick Decision: Is LMI Right for This Workload? |
| 17 | |
| 18 | | Signal | LMI is a strong fit | Standard Lambda is better | |
| 19 | | -------------- | --------------------------------------------------------------------------------------- | ------------------------------------------------------ | |
| 20 | | Traffic | Steady, predictable, 50M+ req/mo | Bursty, unpredictable, long idle | |
| 21 | | Cost | Duration-heavy spend at scale | Low or sporadic invocations | |
| 22 | | Cold starts | Unacceptable (LMI eliminates for provisioned capacity; scale-out may have brief delays) | Tolerable or mitigated by SnapStart | |
| 23 | | Compute | Latest CPUs, specific families, high network bandwidth | Standard Lambda memory/CPU sufficient | |
| 24 | | Isolation | Dedicated EC2 instances in your account, full VPC control | Shared Firecracker micro-VMs acceptable | |
| 25 | | Scale-to-zero | Not needed (execution environments always running) | Required (pay nothing when idle) | |
| 26 | | Code readiness | Thread-safe (Node.js/Java/.NET) or any Python code | Non-thread-safe Node.js/Java/.NET, expensive to change | |
| 27 | |
| 28 | ## Instructions |
| 29 | |
| 30 | ### Step 1: Assess the Workload |
| 31 | |
| 32 | Gather these signals before recommending: |
| 33 | |
| 34 | 1. **Traffic pattern**: Steady vs bursty? Requests per second? |
| 35 | 2. **Current costs**: Monthly Lambda spend? Existing Savings Plans? |
| 36 | 3. **Runtime**: Node.js, Java, .NET, or Python? |
| 37 | 4. **Memory/CPU**: How much memory? CPU-bound or I/O-bound? |
| 38 | 5. **Execution duration**: Average and P99? |
| 39 | 6. **Concurrency readiness**: Thread safety (Node.js/Java/.NET)? Shared `/tmp` paths? Per-invocation DB connections? |
| 40 | 7. **VPC**: Already in a VPC? Private resource access needed? |
| 41 | |
| 42 | #### Deriving LMI Configuration from Metrics |
| 43 | |
| 44 | If Lambda Insights is enabled on the function, use these metrics to calculate your starting configuration. If Lambda Insights is not enabled, suggest adding it to gather accurate workload data — but only proceed wi |