AWS Lambda Managed Instances with Java 25 and AWS SAM - Part 3 Create Lambda function with LMI compute type
Source: Dev.to
Introduction
In part 1 of the series we explained the ideas behind AWS Lambda Managed Instances (LMI) and introduced our sample application.
In part 2 we described what a Lambda Capacity Provider is and how to create it with AWS SAM.
In this article we cover how to create Lambda functions and attach them to the already‑created Capacity Provider.
When creating a Lambda function with the LMI compute type via the AWS Lambda console, an Additional configuration section appears with two choices:
- Lambda (default) – the traditional compute type.
- Lambda managed instance – the new LMI option.
The compute type must be chosen up front and cannot be changed later because each type uses a different concurrency model.
We’ll use AWS SAM as infrastructure‑as‑code (IaC). The sample application is available in the GitHub repository aws‑lambda‑java‑25‑lmi. The relevant SAM template sections are shown below.
Global Function Settings
Globals:
Function:
Runtime: java25
MemorySize: 2048
CapacityProviderConfig:
Arn: !Sub ${MyCapacityProvider.Arn}
ExecutionEnvironmentMemoryGiBPerVCpu: 2
PerExecutionEnvironmentMaxConcurrency: 32
FunctionScalingConfig:
MinExecutionEnvironments: 1
MaxExecutionEnvironments: 3
- Runtime –
java25(the managed Java 25 runtime). - MemorySize –
2048MB (the current minimum supported RAM for LMI). - CapacityProviderConfig – selecting the LMI compute type by referencing an existing capacity provider.
- FunctionScalingConfig – defines the scaling limits for the function.
Supported Runtimes for LMI
| Language | Minimum Version |
|---|---|
| Java | Java 21 and later |
| Python | Python 3.13 and later |
| Node.js | Node.js 22 and later |
| .NET | .NET 8 and later |
Additional runtimes will be added in the future.
CapacityProviderConfig Details
| Property | Description | Example / Range |
|---|---|---|
| Arn | ARN of the existing capacity provider (see part 2). | !Sub ${MyCapacityProvider.Arn} |
| ExecutionEnvironmentMemoryGiBPerVCpu | Memory (GiB) allocated per vCPU for execution environments. Valid range: 2.0 (2:1) to 8.0 (8:1). | 2 |
| PerExecutionEnvironmentMaxConcurrency | Maximum concurrent requests per execution environment. Recommended default for Java is 32. | 32 |
The PerExecutionEnvironmentMaxConcurrency setting distinguishes LMI from the default compute type:
- Default (Firecracker microVM) – one request per execution environment; memory can range from 128 MB to 10 GB.
- LMI – multiple concurrent requests per environment (e.g., 32) but requires at least 2048 MB of memory.
You can tune memory and concurrency to optimise price‑performance, monitoring memory consumption as the application scales.
FunctionScalingConfig Details
| Property | Description | Valid Range |
|---|---|---|
| MinExecutionEnvironments | Minimum number of execution environments that can be provisioned. | 0 – 15000 (set to 1 in the example) |
| MaxExecutionEnvironments | Maximum number of execution environments that can be provisioned. | 0 – 15000 (set to 3 in the example) |
These settings control the scaling behaviour of a Lambda Managed Instances function. See the AWS documentation for more on Scaling Lambda Managed Instances.
When you run sam deploy -g, publishing a function version occurs automatically. The new version becomes active on the capacity provider instances once published.
Viewing the Configuration
After deployment you can inspect the capacity provider and function scaling settings in the Configuration tab of the Lambda console.
If you set both MinExecutionEnvironments and MaxExecutionEnvironments to 0, the function is effectively disabled, avoiding any runtime costs. With the values 1 and 3 (as in the IaC example), you’ll see the underlying EC2 instances on the Amazon EC2 service page. These instances are identified by the Operator property starting with scaler.lambda. Direct access (e.g., SSH) to these LMI instances is not permitted.
In the Capacity providers view, selecting your provider (e.g., CapacityProviderForJava25LMI) and opening the Function versions tab shows all Lambda functions and their versions linked to that provider.
Next Steps
In the next part of the series we will cover:
- Monitoring Lambda Managed Instances
- Currently unsupported features
- Ongoing challenges
- Pricing considerations