Closed
Description
Is there an existing issue for this?
- I have searched the existing issues
Current Behavior
I'm deploying a couple of lambdas to localstack using nodejs aws cdk. When only a single lambda is deployed, everything works fine. However when I deploy a second one, the first lambda becomes unusable because it fails to start with an error like this
An error occurred (ServiceException) when calling the Invoke operation (reached max retries: 2): [ab187a47-fc9c-48af-801b-51cf9716e147] Internal error while executing lambda localstack-schema-export-test-rest-api:None. Caused by AssignmentException: Could not start new environment: ContainerException:
While the second lambda works fine. Even if I then redeploy using cdk without the second lambda, the first lambda stays unusable until I clear the localstack docker container.
Example cdk:
const app = new App();
class TestStack extends Stack {
constructor(scope: App) {
super(scope);
new nodejs.NodejsFunction(this, 'handler', {
functionName: `first-lambda`,
timeout: Duration.seconds(30),
runtime: lambda.Runtime.NODEJS_22_X,
});
new nodejs.NodejsFunction(this, 'handler', {
functionName: `second-lambda`,
timeout: Duration.seconds(30),
runtime: lambda.Runtime.NODEJS_22_X,
});
}
}
new TestStack(app, 'TestStack');
Expected Behavior
All deployed lambdas are able to be invoked
How are you starting LocalStack?
With the localstack
script
Steps To Reproduce
How are you starting localstack (e.g., bin/localstack
command, arguments, or docker-compose.yml
)
LOCALSTACK_SERVICES=serverless,sqs,sns,sts,ssm,s3,cloudformation,lambda,iam,apigateway,stepfunctions,events localstack start -d
Client commands (e.g., AWS SDK code snippet, or sequence of "awslocal" commands)
cdklocal bootstrap --app="npx ts-node path-to-app"
cdklocal deploy --app="npx ts-node path-to-app"
awslocal lambda invoke --function-name first-lambda output.txt
Environment
- OS: macOS 15.5
- LocalStack:
2025-05-19 09:41:25 LocalStack version: 4.4.1.dev6
2025-05-19 09:41:25 LocalStack build date: 2025-05-12
2025-05-19 09:41:25 LocalStack build git hash: e7383de31
Anything else?
No response