
For a decade, 900 seconds was the hard wall on a single Lambda invocation. If one continuous computation needed longer, Lambda was the wrong tool and you knew it. That wall just moved for one specific case: functions running on Lambda Managed Instances, invoked asynchronously or through an event source mapping, can now run for up to 90 minutes, six times the old limit. Synchronous request/response invocations are still capped at 15 minutes.
I wanted the real thing rather than the announcement, so I built a Lambda Managed Instances (LMI) function and ran a single continuous invocation past the old 900-second ceiling to confirm it genuinely holds. It does. The setup is more involved than a normal Lambda, and a few steps are not obvious from the first read of the docs, so this is the practitioner's version with the parts that actually tripped me up.
To be precise about scope up front: I ran one invocation for 20 minutes, not the full 90. Twenty minutes is enough to prove the behavior that matters, that a single invocation now runs well past the old limit, without holding a provisioned instance longer than necessary. The ceiling is 90 minutes; what I measured is a clean crossing of the old 15-minute wall and then some.
All numbers below are from runs on Python 3.13 in us-west-2.
What Managed Instances actually is
Classic Lambda runs your code in a Firecracker microVM that AWS spins up on demand. LMI runs your function on current-generation EC2 instances instead, while Lambda still handles instance lifecycle, patching, routing, and scaling. You get the EC2 pricing model and longer runtimes; you give up the pure per-millisecond, scale-to-zero behavior. The billing follows EC2 instance time, not the classic per-GB-second model, which is the single most important thing to understand before you turn it on.
The function code itself is ordinary. My handler is a plain loop that does light CPU work and logs a heartbeat every minute with its elapsed time and remaining budget:
def handler(event, context):
run_seconds = int(event.get("run_seconds", 1200))
start = time.time()
minute = 0
while time.time() - start < run_seconds:
if time.time() - start >= minute * 60:
print(json.dumps({
"heartbeat_minute": minute,
"elapsed_s": round(time.time() - start, 1),
"remaining_ms": context.get_remaining_time_in_millis(),
"past_15_min": (time.time() - start) > 900,
}))
minute += 1
_ = sum(i * i for i in range(10000))
time.sleep(1)
return {"status": "DONE", "elapsed_s": round(time.time() - start, 1)}
Nothing about that code is special. The timeout, the capacity, and the invocation path are where LMI differs.
The proof, from the logs
I set the function timeout to 1800 seconds and invoked it asynchronously with a 20-minute workload. The first heartbeat told me the longer timeout was really in effect:
remaining_ms at start = 1,799,999
A classic Lambda would report at most 900,000. Then the run crossed the line that used to be impossible:
{"heartbeat_minute": 15, "elapsed_s": 900.5, "remaining_ms": 899532, "past_15_min": true}
{"heartbeat_minute": 16, "elapsed_s": 960.5, "remaining_ms": 839501, "past_15_min": true}
{"heartbeat_minute": 19, "elapsed_s": 1140.6, "remaining_ms": 659406, "past_15_min": true}
And the platform's own report gives the authoritative number. The platform.report log record for the invocation shows:
durationMs = 1,200,625.546
That is a single invocation billed for roughly 20 minutes of continuous execution. The classic hard cap is 900,000 ms. This one ran about a third past it, in one invocation, with no chaining, no state handoff, no Step Functions. That is the whole point of the feature in one number.
The setup gotchas
This is the part worth the price of admission, because the happy-path docs do not dwell on these and each one cost me time.
A function is not enough; you need a capacity provider. LMI functions run inside a capacity provider, which is the security and compute boundary. Creating one requires a VPC configuration (subnets and a security group) and an operator IAM role that lets Lambda manage EC2 on your behalf. The managed policy AWSLambdaManagedEC2ResourceOperator grants exactly those permissions, with a trust policy for lambda.amazonaws.com. The default VPC works fine for a test.
The function memory floor is 2048 MB. My first create_function call failed with a plain validation error: LMI functions must have memory greater than or equal to 2048. A 512 MB function that is perfectly normal on classic Lambda is rejected here. Set it to at least 2048 and move on.
The function is created but not invocable. After creation, the function sits in state ActiveNonInvocable. This surprised me, because classic Lambda is invocable the moment it is active. LMI does not cold-start on an incoming invocation. It scales asynchronously on resource signals, so until capacity exists, there is nothing to run your code. An invoke at this point goes nowhere.
You make it invocable by provisioning capacity. Publish a version, then set a minimum on it:
version = lam.publish_version(FunctionName=FN)["Version"]
lam.put_function_scaling_config(
FunctionName=FN, Qualifier=version,
FunctionScalingConfig={"MinExecutionEnvironments": 1, "MaxExecutionEnvironments": 2},
)
Setting MinExecutionEnvironments to 1 forces Lambda to provision an execution environment, which brings the function to an invocable state. One caution: calling put_function_scaling_config immediately after publish_version can throw a transient ResourceConflictException. A short retry with backoff clears it.
The instances are hidden by default, not missing. I looked for the EC2 instance with a plain describe_instances and found nothing, in any state. It is easy to conclude that LMI instances never show up in your account, but that is not the case. Since EC2 Managed Resource Visibility launched in April 2026, instances that an AWS service launches on your behalf are hidden from the EC2 console and from DescribeInstances unless you ask for them. One flag brings them back:
aws ec2 describe-instances --include-managed-resources \
--filters Name=instance-state-name,Values=pending,running \
--query 'Reservations[].Instances[].[InstanceId,InstanceType,State.Name,LaunchTime]' \
--output table
Each instance carries the tags aws:ec2:managed-launch = lambda-managed-instances and aws:lambda:capacity-provider = <capacity provider ARN>, which is the reliable way to tell which capacity provider owns it. If you leave instance types at the default, Lambda picks them for you (m7a.xlarge is a typical choice), and a capacity provider can run more than one instance. Hidden instances still run and still bill, so this check is worth running after every teardown.
You can also make managed instances visible in the EC2 console with the ModifyManagedResourceVisibility setting, but that change is account-wide and also surfaces EKS, ECS, and other service-managed instances for everyone in the account. For a single check, the flag is the lighter option. For watching the run itself, CloudWatch logs and the platform.report records remain the best view.
Changes from a normal Lambda, in one place
If you already know how to deploy a classic Lambda, these are the only things that change. The snippets are the exact boto3 calls from my run.
1. Two IAM roles instead of one. The execution role is the same as always (AWSLambdaBasicExecutionRole). The new one is an operator role that Lambda assumes to manage EC2 for you, with the managed policy AWSLambdaManagedEC2ResourceOperator and a trust policy for lambda.amazonaws.com.
2. A capacity provider, created before the function. This is the piece with no classic Lambda equivalent. It holds the VPC, the operator role, and the instance requirements. Wait for it to reach Active before creating the function.
lam.create_capacity_provider(
CapacityProviderName="lmi-lab-cp",
VpcConfig={"SubnetIds": subnets, "SecurityGroupIds": [sg]},
PermissionsConfig={"CapacityProviderOperatorRoleArn": operator_role_arn},
InstanceRequirements={"Architectures": ["x86_64"]},
CapacityProviderScalingConfig={"ScalingMode": "Auto"},
)
3. Three settings on create_function. CapacityProviderConfig is what makes it a Managed Instances function. Timeout goes above 900 (I used 1800; the async ceiling is 5400). MemorySize must be at least 2048.
lam.create_function(
FunctionName="lmi-lab-fn",
Runtime="python3.13",
Role=exec_role_arn,
Handler="lmi_handler.handler",
Code={"ZipFile": zip_bytes},
Timeout=1800, # classic Lambda rejects anything above 900
MemorySize=2048, # LMI minimum
CapacityProviderConfig={
"LambdaManagedInstancesCapacityProviderConfig": {"CapacityProviderArn": cp_arn}
},
)
4. Publish a version and give it capacity. A classic function is invocable once it is Active. An LMI function stays ActiveNonInvocable until you publish a version and set MinExecutionEnvironments on it, as shown above. Poll get_function on that version until it reports Active.
5. Invoke the version, asynchronously. Invoke the qualified version (or an alias pointing to it), not $LATEST, because the capacity is attached to the version. Use InvocationType="Event" or an event source mapping. A synchronous RequestResponse call is still capped at 15 minutes, whatever the function timeout says.
lam.invoke(
FunctionName="lmi-lab-fn:1", # qualified version, not $LATEST
InvocationType="Event", # async: up to 90 minutes
Payload=json.dumps({"run_seconds": 1200}).encode(),
)
6. Expect more than one invocation per environment. Classic Lambda runs one invocation per execution environment at a time. LMI can run several at once in the same environment. For Python this uses separate processes, so global variables are not shared, but /tmp is shared and memory use multiplies with concurrency. Use context.aws_request_id in any temp file names. If you do not set them, Lambda applies these defaults: PerExecutionEnvironmentMaxConcurrency of 16 and ExecutionEnvironmentMemoryGiBPerVCpu of 2.0. Both live under CapacityProviderConfig and can be lowered for CPU-heavy or memory-heavy work. My test ran a single invocation, so this did not come up, but it matters for real workloads.
7. Tear down in order. Delete the function first, which detaches its versions from the capacity provider. Then delete the capacity provider, retrying until the detach finishes, because it cannot be deleted while versions are still attached. Then delete the two roles and the log group. An LMI function left with capacity keeps an instance billing even when nothing invokes it.
Do not try to terminate the instances yourself. Deleting the capacity provider is what removes them, and it is quick: the function is typically gone within a minute of delete-function, and the instances move to terminated shortly after the capacity provider delete is accepted. If you create the function in the console instead of code, there is one more thing to clean up: the console makes its own execution role (named like <function>-role-xxxxxxxx under service-role/) plus a customer-managed AWSLambdaBasicExecutionRole-<id> policy. Detach and delete the policy after the role, or it stays behind in IAM. Finish with the --include-managed-resources check above to confirm nothing is still running.
The same setup in the console
If you prefer clicking to code, the Lambda console covers almost all of it. The order is the same: operator role, capacity provider, then the function.
Operator role (IAM console). Go to IAM, then Roles, then Create role. Choose Lambda as the trusted service, attach AWSLambdaManagedEC2ResourceOperator, and give it a name.
Capacity provider (Lambda console). In the Lambda console, open Capacity providers from the left menu and choose Create capacity provider. Enter a name, then select the VPC, subnets, security group, and the operator role you just created. The default VPC is fine for a test. Under Advanced settings, choose the architecture (x86_64 or arm64) and set a maximum vCPU count. Keep that number small for a test so a mistake cannot scale up far. Leave instance types at the default unless you need a specific family. Create it and wait for the status to show Active.
Function. Open Event Functions, choose Create function, then Author from scratch. Pick a runtime and the same architecture as the capacity provider. Under Additional configurations, set Compute type to Lambda Managed Instances, and the capacity provider you created should already be selected. Set memory to at least 2048 MB, then choose Create function. Creation takes several minutes, because the console publishes a version and provisions capacity on the capacity provider for you. This is the step you do by hand with publish_version and put_function_scaling_config in code.
Timeout. Under Configuration, then General configuration, set Timeout up to 5400 seconds. If the field will not accept a value above 900, set it from the CLI instead:
aws lambda update-function-configuration --function-name <your-function> --timeout 5400
Invoking it. This is the one place the console cannot get you the long run. The Test button makes a synchronous call, and synchronous calls stop at 15 minutes whatever the timeout says. For a run past 15 minutes, invoke the published version asynchronously from the CLI, or attach an asynchronous trigger such as an S3 event or an EventBridge rule:
aws lambda invoke --function-name <your-function>:1 --invocation-type Event \
--cli-binary-format raw-in-base64-out --payload '{"run_seconds":1200}' out.json
Cleanup. Delete the function, then the capacity provider, then the roles. Remember the extra execution role and policy the console creates, covered in step 7 above.
Cost, stated plainly
Because LMI bills on EC2 instance time, the cost model is "how long was an instance up," not "how many GB-seconds did I consume." For this experiment, one instance was provisioned for roughly the setup, the 20-minute run, and teardown, well under an hour. On a small general-purpose instance that is a spend of well under a dollar. The important operational habit is that an idle provisioned instance still bills, so I deleted the function and the capacity provider the moment the run finished. Leaving MinExecutionEnvironments at 1 on a forgotten test function is how a few cents an hour quietly becomes a line item.
When to reach for this, and when not
The 90-minute timeout is the right tool for one continuous computation that cannot be meaningfully checkpointed: a long model inference, a large media transcode, a batch job that holds state in memory and would be awkward to split. For that shape, LMI removes the wall that used to force you off Lambda entirely.
It is the wrong tool for a workflow that spends most of its time waiting. If your long duration is mostly idle time between steps, a human approval, a callback, a scheduled delay, then Lambda durable functions are the better fit, because they suspend and release compute during the wait instead of holding a provisioned instance the whole time. I wrote up durable functions separately, including the two-invocation suspend-and-resume proof from their execution history.
A simple way to decide: if the clock is long because your code is busy, Managed Instances. If the clock is long because your code is waiting, durable functions. The two features look similar from the headline ("Lambda can run longer now") and solve genuinely different problems underneath.
For the waiting case, see the companion piece, "Lambda Durable Functions in Practice: What the Execution History Actually Shows," which walks through the two-invocation suspend-and-resume proof and the replay footgun that silently executes the wrong action if you miss it.
Top comments (0)