Deployment works fine but Lambda invocation fails with error errorType":"Runtime.ImportModuleError" "errorMessage":"Error: Cannot find module Require stack:- /var/task/test-lambdahandler-override.js - /var/runtime/UserFunction.js

Hello,

We run our integration test cases on localstack docker image. Currently we are using localstack-light:0.12.16 version. We are using AWS cloudformation template to deploy lambda functions. We deploy all source code to an S3 bucket in zip format. So far all test cases were running fine. But now, when we added few more files to our src folder which doesn’t have to do anything with the earlier code, all our integration test cases started failing. The deployment to localstack is working fine. Only on lambda invocation we are facing this error - errorType":"Runtime.ImportModuleError","errorMessage":"Error: Cannot find module './lambdahandler'\nRequire stack:\n- /var/task/test-lambdahandler-override.js\n- /var/runtime/UserFunction.js\
I even checked the S3 bucket and it does have the lambdahandler file stored in it.
When I remove some files from the source code then all integration test cases starts passing again and everything works fine. What am I missing here?

Hi @chaitrali

Please check out our new Lambda implementation in LocalStack v2 that brings many improvements and likely resolves your issue.

1 Like