Generated banner for AWS Lambda Managed Instances
Generated logo for AWS Lambda Managed Instances

AWS Lambda Managed Instances

AWS LabsOfficialPublished by AWS Labs

  • Skill
  • Tool integration
  • Cloud and DevOps
  • Apache-2.0
  • Low risk
  • Has scripts

From the author

Evaluate, 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 Lambda, scheduled scaling for LMI, Lambda cost optimization with Reserved Instances or Savings Plans. Also trigger when users describe high-volume predictable workloads seeking cost savings, want to scale LMI capacity on a schedule, or compare Lambda vs EC2 for steady-state traffic. For standard Lambda without LMI, use the aws-lambda skill instead.
— the description by AWS Labs

AutoGineer summary

Written by AutoGineer from the skill’s own files, not by the author

This skill provides a structured approach to migrating Lambda functions to Lambda Managed Instances (LMI). LMI allows you to run Lambda functions on dedicated EC2 instances within your account, combining the ease of Lambda development with the cost-efficiency and hardware flexibility of EC2. The skill guides users through workload assessment, cost comparison, concurrency tuning, and infrastructure setup, ensuring that LMI is the right fit for their specific traffic patterns and performance requirements.

What it does

  • Assesses workload suitability for LMI based on traffic patterns and cost.
  • Provides formulas for calculating concurrency, memory, and execution environment requirements.
  • Guides the configuration of capacity providers, instance types, and scaling controls.
  • Reviews code for concurrency and thread-safety requirements across supported runtimes.
  • Assists in setting up infrastructure via CLI, SAM, or CDK.
  • Offers troubleshooting steps for common deployment and performance issues.

When to use it

  • When evaluating if LMI is more cost-effective than standard Lambda for steady-state traffic.
  • When you need to eliminate cold starts for high-volume, predictable workloads.
  • When you require specific EC2 instance types or hardware configurations for Lambda functions.
  • When you need to implement scheduled scaling for predictable traffic spikes.
  • When you need to migrate existing Lambda functions to a more performant or cost-optimized environment.

Advantages

  • Optimizes costs for high-volume, steady-state workloads.
  • Eliminates cold starts through provisioned capacity.
  • Provides access to diverse EC2 instance families and Graviton processors.
  • Allows for granular control over scaling and resource utilization.
  • Maintains the familiar Lambda developer experience while leveraging EC2 infrastructure.

Usage examples

“Is my Lambda function a good candidate for LMI?”
The agent will ask for your current monthly Lambda spend, traffic patterns (steady vs. bursty), and runtime to perform a cost-benefit analysis and determine if LMI is appropriate.
“How do I configure LMI for a CPU-intensive Python application?”
The agent will recommend an appropriate instance family (e.g., C-series), suggest a memory-to-vCPU ratio, and provide the necessary configuration steps for your chosen IaC framework.
“Help me set up scheduled scaling for my LMI function.”
The agent will guide you through using EventBridge Scheduler to adjust your Min/Max execution environments based on your specific business hours or traffic schedule.
“My LMI function is experiencing 429 throttles. How do I fix it?”
The agent will help you analyze your current scaling configuration and suggest adjustments to MinExecutionEnvironments or TargetResourceUtilization to resolve the throttling.

Install

  1. Download the skill as a ZIP:

    https://mp-staging.autogineer.com/agent-skills/awslabs/aws-lambda-managed-instances/download
  2. Unzip it into the cross-client skills folder of your project:

    mkdir -p .agents/skills && unzip aws-lambda-managed-instances.zip -d .agents/skills

Documentation by AWS Labs

AWS Lambda Managed Instances (LMI)

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.

For standard Lambda development, see aws-lambda skill. For SAM/CDK deployment, see aws-serverless-deployment skill.

When to Load Reference Files

Quick Decision: Is LMI Right for This Workload?

SignalLMI is a strong fitStandard Lambda is better
TrafficSteady, predictable, 50M+ req/moBursty, unpredictable, long idle
CostDuration-heavy spend at scaleLow or sporadic invocations
Cold startsUnacceptable (LMI eliminates for provisioned capacity; scale-out may have brief delays)Tolerable or mitigated by SnapStart
ComputeLatest CPUs, specific families, high network bandwidthStandard Lambda memory/CPU sufficient
IsolationDedicated EC2 instances in your account, full VPC controlShared Firecracker micro-VMs acceptable
Scale-to-zeroNot needed (execution environments always running)Required (pay nothing when idle)
Code readinessThread-safe (Node.js/Java/.NET) or any Python codeNon-thread-safe Node.js/Java/.NET, expensive to change

Instructions

Step 1: Assess the Workload

Gather these signals before recommending:

  1. Traffic pattern: Steady vs bursty? Requests per second?

  2. Current costs: Monthly Lambda spend? Existing Savings Plans?

  3. Runtime: Node.js, Java, .NET, or Python?

  4. Memory/CPU: How much memory? CPU-bound or I/O-bound?

  5. Execution duration: Average and P99?

  6. Concurrency readiness: Thread safety (Node.js/Java/.NET)? Shared /tmp paths? Per-invocation DB connections?

  7. VPC: Already in a VPC? Private resource access needed?

Deriving LMI Configuration from Metrics

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 with the user's explicit confirmation, as adding the Insights layer may affect function performance or cold start times.

To check if Lambda Insights is enabled, look for a LambdaInsightsExtension layer on the function. To add it, find the latest layer ARN for your region from the Lambda Insights documentation and attach the CloudWatchLambdaInsightsExecutionRolePolicy managed policy to the function's execution role.

Target max concurrency (from cpu_total_time and Duration):

PerExecutionEnvironmentMaxConcurrency = floor((0.5 × Duration) / cpu_total_time)

This targets 50% CPU utilization at full concurrency, leaving headroom for scaling.

Memory allocation (from memory_utilization and current memory):

MemorySize = min(32768, max(2048, MaxConcurrency × (memory_utilization / 100) × current_allocated_memory))

This overestimates (assumes no shared base memory) but provides a safe starting point. The outer min caps the result at the 32 GB (32768 MB) LMI maximum.

Minimum execution environments (from baseline ConcurrentExecutions):

MinExecutionEnvironments = max(3, ceil(baseline_concurrent_executions × 2 / MaxConcurrency))

Targets 50% concurrency utilization to leave headroom for traffic bursts.

Without Lambda Insights: Start with the runtime's default max concurrency, 2 GB memory, and MinExecutionEnvironments = 3. Adjust during testing.

Step 2: Build the Cost Comparison

REQUIRED: Present a cost comparison before recommending LMI. Compare at minimum:

ScenarioWhen it wins
Lambda on-demandLow volume, bursty traffic
LMI on-demandHigh volume, steady traffic

Rule of thumb: LMI becomes cost-competitive when your Lambda spend exceeds ~$1,000/month with steady traffic.

For discount analysis (Savings Plans, Reserved Instances), refer users to the AWS Pricing Calculator and references/cost-comparison.md for formulas and worked examples. Discount recommendations require workload-specific forecasting beyond this skill's scope.

Step 3: Configure the Deployment

Instance families (~450 types): C-series (compute, .xlarge+), M-series (general, .large+), R-series (memory, .large+). ARM (Graviton) for best price-performance.

Memory-to-vCPU ratios: 2:1 (default, CPU-bound work), 4:1 (general/mixed workloads), 8:1 (memory-heavy or Python apps). Min 2 GB, max 32 GB.

Multi-concurrency defaults/vCPU: Node.js 64, Java 32, .NET 32, Python 16.

Scaling: MinExecutionEnvironments (default 3), MaxVCpuCount (default 400), TargetResourceUtilization.

Scheduled scaling: For predictable traffic (business hours, marketing events), use EventBridge Scheduler to adjust Min/Max execution environments on a one-time or recurring schedule — scale up before peak, scale down or to zero when idle.

See references/configuration-guide.md for decision trees and detailed tuning.

Step 4: Migrate the Code

Review code for concurrency safety. LMI runs multiple invocations concurrently per execution environment, but the model differs by runtime:

  • Python: Process-based isolation — globals are NOT shared. No thread-safety changes needed. Focus on /tmp conflicts and memory sizing (per-process × concurrency).

  • Node.js: Worker threads — globals shared within a worker. Requires async safety. Callback handlers not supported on Node.js 22.

  • Java/.NET: OS threads/Tasks — handler shared across threads. Requires full thread safety.

Common issues (all runtimes): shared /tmp paths, per-invocation DB connections. Thread-safety issues (Node.js/Java/.NET only): mutable globals, non-thread-safe libs.

See references/thread-safety.md for the review checklist and references/migration-patterns.md for runtime-specific before/after code.

Step 5: Set Up Infrastructure
  1. Create two IAM roles: execution role (for the function) and operator role (for capacity provider EC2 management)

  2. Configure VPC with subnets across multiple AZs (recommended 3+ for resiliency)

  3. Create capacity provider with VPC config and scaling limits

  4. Create or update function with capacity provider attachment

  5. Publish a version (triggers instance provisioning)

See references/infrastructure-setup.md for CLI commands and SAM templates.

Step 6: Validate and Cut Over
  1. Deploy to a non-production environment first

  2. Monitor CloudWatch: CPU utilization, memory, concurrency, throttle rate. If you observe low CPU utilization or ongoing throttles, see references/troubleshooting.md for metric-specific adjustment guidance.

  3. Shift traffic to the LMI function (note: weighted alias shifting between LMI and non-LMI functions is not currently supported)

  4. Compare costs after 1-2 weeks of production data

  5. Decommission standard Lambda once stable

Best Practices

Configuration
  • Do: Start with 2:1 ratio and runtime default concurrency

  • Do: Use ARM (Graviton) unless x86 dependencies exist

  • Do: Let Lambda choose instance types unless specific hardware needed

  • Do: Set MaxVCpuCount to control cost ceiling

  • Don't: Set MinExecutionEnvironments below 3 in production (reduces multi-AZ coverage). Non-prod environments can use 1 as the minimum.

  • Don't: Over-restrict instance types (lowers availability)

Migration
  • Do: Start with I/O-heavy functions (benefit most from multi-concurrency; CPU-bound functions compete for same CPU)

  • Do: Review code for concurrency safety before attaching to capacity provider (thread safety for Node.js/Java/.NET; /tmp and memory for Python)

  • Do: Plan traffic shifting strategy based on your invocation source (weighted alias shifting between LMI and non-LMI functions is not currently supported)

  • Do: Include request IDs in all log statements

  • Do: Initialize DB pools and SDK clients outside the handler

  • Do: Estimate total /tmp usage under max concurrency

  • Don't: Write to hardcoded /tmp paths without request-unique naming

  • Don't: Skip cost comparison — LMI is not always cheaper

Operations
  • Do: Set CloudWatch alarms on throttle rate > 1% and CPU > 80%

  • Do: Use scheduled scaling (EventBridge Scheduler) for predictable traffic — raise Min/Max before peak periods and lower them (or scale to zero) when idle

  • Don't: Manually terminate LMI EC2 instances (delete the capacity provider instead)

  • Don't: Forget to publish a version — unpublished functions cannot run on LMI

  • Don't: Rely on a deactivated (Min=Max=0) function to self-recover — schedule an explicit scale-up to reactivate it

Limits Quick Reference

ResourceLimit
Memory2 GB min, 32 GB max
Concurrency/vCPU64 (Node.js), 32 (Java/.NET), 16 (Python)
Instance lifespan~12 hours (auto-replaced by Lambda)
EE lifespan~4 hours (auto-replaced by Lambda)
RuntimesNode.js, Java, .NET, Python
Instance familiesC (.xlarge+), M (.large+), R (.large+)
ScalingDoubles within 5 min without throttles

Troubleshooting Quick Reference

IssueCauseFix
429 throttlesTraffic exceeds scaling speedIncrease MinExecutionEnvironments or lower TargetResourceUtilization
Function stuck PENDINGProvisioning instancesWait; check VPC/IAM config
Architecture mismatchFunction ≠ capacity provider archAlign both to same architecture
Cannot terminate instancesManaged by capacity providerDelete capacity provider instead
Race conditionsCode not thread-safeSee references/thread-safety.md

See references/troubleshooting.md for detailed resolution steps.

Configuration

AWS CLI Setup

REQUIRED: AWS credentials configured on the host machine.

Verify access: Run aws sts get-caller-identity

Regional Availability

Available in all commercial AWS Regions except Israel (Tel Aviv), Middle East (Bahrain), Middle East (UAE), and Asia Pacific (Auckland).

Check the Lambda Managed Instances documentation for the latest regional availability.

Language Selection

Default: TypeScript

Override: "use Python" → Python, "use JavaScript" → JavaScript. When not specified, ALWAYS use TypeScript.

IaC Framework Selection

Default: CDK

Override: "use SAM" → SAM YAML, "use CloudFormation" → CloudFormation YAML. When not specified, ALWAYS use CDK.

Error Scenarios

Serverless MCP Server Unavailable
  • Inform user: "AWS Serverless MCP not responding"

  • Ask: "Proceed without MCP support?"

  • DO NOT continue without user confirmation

Unsupported Runtime
  • State: "Lambda Managed Instances does not yet support [runtime]"

  • List supported runtimes

  • Suggest standard Lambda as alternative

Unsupported Region
  • State: "Lambda Managed Instances is not available in [region]"

  • Name the excluded regions: Israel (Tel Aviv), Middle East (Bahrain), Middle East (UAE), Asia Pacific (Auckland)

  • Suggest the nearest supported region

Resources

Files

LICENSE


                                 Apache License
                           Version 2.0, January 2004
                        http://www.apache.org/licenses/

   TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION

   1. Definitions.

      "License" shall mean the terms and conditions for use, reproduction,
      and distribution as defined by Sections 1 through 9 of this document.

      "Licensor" shall mean the copyright owner or entity authorized by
      the copyright owner that is granting the License.

      "Legal Entity" shall mean the union of the acting entity and all
      other entities that control, are controlled by, or are under common
      control with that entity. For the purposes of this definition,
      "control" means (i) the power, direct or indirect, to cause the
      direction or management of such entity, whether by contract or
      otherwise, or (ii) ownership of fifty percent (50%) or more of the
      outstanding shares, or (iii) beneficial ownership of such entity.

      "You" (or "Your") shall mean an individual or Legal Entity
      exercising permissions granted by this License.

      "Source" form shall mean the preferred form for making modifications,
      including but not limited to software source code, documentation
      source, and configuration files.

      "Object" form shall mean any form resulting from mechanical
      transformation or translation of a Source form, including but
      not limited to compiled object code, generated documentation,
      and conversions to other media types.

      "Work" shall mean the work of authorship, whether in Source or
      Object form, made available under the License, as indicated by a
      copyright notice that is included in or attached to the work
      (an example is provided in the Appendix below).

      "Derivative Works" shall mean any work, whether in Source or Object
      form, that is based on (or derived from) the Work and for which the
      editorial revisions, annotations, elaborations, or other modifications
      represent, as a whole, an original work of authorship. For the purposes
      of this License, Derivative Works shall not include works that remain
      separable from, or merely link (or bind by name) to the interfaces of,
      the Work and Derivative Works thereof.

      "Contribution" shall mean any work of authorship, including
      the original version of the Work and any modifications or additions
      to that Work or Derivative Works thereof, that is intentionally
      submitted to Licensor for inclusion in the Work by the copyright owner
      or by an individual or Legal Entity authorized to submit on behalf of
      the copyright owner. For the purposes of this definition, "submitted"
      means any form of electronic, verbal, or written communication sent
      to the Licensor or its representatives, including but not limited to
      communication on electronic mailing lists, source code control systems,
      and issue tracking systems that are managed by, or on behalf of, the
      Licensor for the purpose of discussing and improving the Work, but
      excluding communication that is conspicuously marked or otherwise
      designated in writing by the copyright owner as "Not a Contribution."

      "Contributor" shall mean Licensor and any individual or Legal Entity
      on behalf of whom a Contribution has been received by Licensor and
      subsequently incorporated within the Work.

   2. Grant of Copyright License. Subject to the terms and conditions of
      this License, each Contributor hereby grants to You a perpetual,
      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
      copyright license to reproduce, prepare Derivative Works of,
      publicly display, publicly perform, sublicense, and distribute the
      Work and such Derivative Works in Source or Object form.

   3. Grant of Patent License. Subject to the terms and conditions of
      this License, each Contributor hereby grants to You a perpetual,
      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
      (except as stated in this section) patent license to make, have made,
      use, offer to sell, sell, import, and otherwise transfer the Work,
      where such license applies only to those patent claims licensable
      by such Contributor that are necessarily infringed by their
      Contribution(s) alone or by combination of their Contribution(s)
      with the Work to which such Contribution(s) was submitted. If You
      institute patent litigation against any entity (including a
      cross-claim or counterclaim in a lawsuit) alleging that the Work
      or a Contribution incorporated within the Work constitutes direct
      or contributory patent infringement, then any patent licenses
      granted to You under this License for that Work shall terminate
      as of the date such litigation is filed.

   4. Redistribution. You may reproduce and distribute copies of the
      Work or Derivative Works thereof in any medium, with or without
      modifications, and in Source or Object form, provided that You
      meet the following conditions:

      (a) You must give any other recipients of the Work or
          Derivative Works a copy of this License; and

      (b) You must cause any modified files to carry prominent notices
          stating that You changed the files; and

      (c) You must retain, in the Source form of any Derivative Works
          that You distribute, all copyright, patent, trademark, and
          attribution notices from the Source form of the Work,
          excluding those notices that do not pertain to any part of
          the Derivative Works; and

      (d) If the Work includes a "NOTICE" text file as part of its
          distribution, then any Derivative Works that You distribute must
          include a readable copy of the attribution notices contained
          within such NOTICE file, excluding those notices that do not
          pertain to any part of the Derivative Works, in at least one
          of the following places: within a NOTICE text file distributed
          as part of the Derivative Works; within the Source form or
          documentation, if provided along with the Derivative Works; or,
          within a display generated by the Derivative Works, if and
          wherever such third-party notices normally appear. The contents
          of the NOTICE file are for informational purposes only and
          do not modify the License. You may add Your own attribution
          notices within Derivative Works that You distribute, alongside
          or as an addendum to the NOTICE text from the Work, provided
          that such additional attribution notices cannot be construed
          as modifying the License.

      You may add Your own copyright statement to Your modifications and
      may provide additional or different license terms and conditions
      for use, reproduction, or distribution of Your modifications, or
      for any such Derivative Works as a whole, provided Your use,
      reproduction, and distribution of the Work otherwise complies with
      the conditions stated in this License.

   5. Submission of Contributions. Unless You explicitly state otherwise,
      any Contribution intentionally submitted for inclusion in the Work
      by You to the Licensor shall be under the terms and conditions of
      this License, without any additional terms or conditions.
      Notwithstanding the above, nothing herein shall supersede or modify
      the terms of any separate license agreement you may have executed
      with Licensor regarding such Contributions.

   6. Trademarks. This License does not grant permission to use the trade
      names, trademarks, service marks, or product names of the Licensor,
      except as required for reasonable and customary use in describing the
      origin of the Work and reproducing the content of the NOTICE file.

   7. Disclaimer of Warranty. Unless required by applicable law or
      agreed to in writing, Licensor provides the Work (and each
      Contributor provides its Contributions) on an "AS IS" BASIS,
      WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
      implied, including, without limitation, any warranties or conditions
      of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
      PARTICULAR PURPOSE. You are solely responsible for determining the
      appropriateness of using or redistributing the Work and assume any
      risks associated with Your exercise of permissions under this License.

   8. Limitation of Liability. In no event and under no legal theory,
      whether in tort (including negligence), contract, or otherwise,
      unless required by applicable law (such as deliberate and grossly
      negligent acts) or agreed to in writing, shall any Contributor be
      liable to You for damages, including any direct, indirect, special,
      incidental, or consequential damages of any character arising as a
      result of this License or out of the use or inability to use the
      Work (including but not limited to damages for loss of goodwill,
      work stoppage, computer failure or malfunction, or any and all
      other commercial damages or losses), even if such Contributor
      has been advised of the possibility of such damages.

   9. Accepting Warranty or Additional Liability. While redistributing
      the Work or Derivative Works thereof, You may choose to offer,
      and charge a fee for, acceptance of support, warranty, indemnity,
      or other liability obligations and/or rights consistent with this
      License. However, in accepting such obligations, You may act only
      on Your own behalf and on Your sole responsibility, not on behalf
      of any other Contributor, and only if You agree to indemnify,
      defend, and hold each Contributor harmless for any liability
      incurred by, or claims asserted against, such Contributor by reason
      of your accepting any such warranty or additional liability.

Requirements and compatibility

Written for: Claude Code

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: Claude Code frontmatter, Needs an MCP server

Security

What our scanner noticed· Low risk

  • Scripts that your agent may run

This skill includes scripts that your agent may run. Read them before you use it.

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 Labs
Publisher
AWS Labs (Official)
Source
awslabs/agent-plugins · plugins/aws-serverless/skills/aws-lambda-managed-instances · commit fbefb37
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 Labs.

Download ZIP

The ZIP holds the skill’s files, its licence files and an ATTRIBUTION.md. Download aws-lambda-managed-instances.zip