Open iheffernan opened 3 years ago
So an update here. I can workaround this by Updating the function code with AWS Toolkit, then going into the AWS Console and manually changing the Handler to point to dist/src/app.lambdaHandler
. Would be nice, though, if we could cut out that additional step.
I am not sure our custom TS step gets executed in that flow.
We will have to take a look.
FYI, you can update the handler in the Update Function Configuration dialog if you wish to avoid going to the console.
That's the problem - the console allows me to set the handler to dist/src/app.lambdaHandler
, but if I try to use that path in the Update Function dialogs it gives me an error that says Must be able to locate the handler in the project in order to deploy to Lambda
. Almost like there's some overzealous validation of the Handler path in the Toolkit dialog.
FWIW - once I do set the Handler path in the AWS Console it is retained, regardless of what I put in the AWS Explorer dialog when I do Update Function.
It is over zealous because we currently backtrack from the handler to find where to build the function from.
The fact that the handler doesn't update is probably actually a bug 😄
I was referring to the Update Function Configuration dialog, which does NOT update any code :
I take that last comment back - it does get overwritten on each deployment from AWS Explorer
Ok, that makes sense. Yes, I can update the configuration, but then when I try to actually update the function I get the Must be able to locate...
error.
Like I said, I have a workaround for now, but it would be nice because I'll eventually forget to make the update in the console!
I wanted to circle back on this to see if this was something that you would be able to allow in future versions, e.g. specifying the path to the transpiled code as the Handler in the the Update Function Code dialog.
It is still possible to do this in 2 steps by first updating the code and pointing to the source directory that contains the TypeScript handler and then using the Update Function Configuration dialog to change the Handler to the transpiled code. It would just be nice if you could specify the transpiled Handler when updating the code.
Thanks again...
Still the same issue, any progress?
Still seeing this error when using the AWS Tookit, but no error when running SAM CLI in Terminal
Describe the bug I have a Lambda function written in TypeScript that I can run and debug locally. However, if I try to use AWS Explorer to Update Function Code of a deployed Lambda and then test that deployed Lambda in the AWS Console I always get the following error (my lambda function file is
app.ts
...{ "errorType": "Runtime.ImportModuleError", "errorMessage": "Error: Cannot find module 'app'\nRequire stack:\n- /var/runtime/UserFunction.js\n- /var/runtime/index.js", "trace": [ "Runtime.ImportModuleError: Error: Cannot find module 'app'", "Require stack:", "- /var/runtime/UserFunction.js", "- /var/runtime/index.js", " at _loadUserApp (/var/runtime/UserFunction.js:100:13)", " at Object.module.exports.load (/var/runtime/UserFunction.js:140:17)", " at Object.<anonymous> (/var/runtime/index.js:43:30)", " at Module._compile (internal/modules/cjs/loader.js:1072:14)", " at Object.Module._extensions..js (internal/modules/cjs/loader.js:1101:10)", " at Module.load (internal/modules/cjs/loader.js:937:32)", " at Function.Module._load (internal/modules/cjs/loader.js:778:12)", " at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:76:12)", " at internal/main/run_main_module.js:17:47" ] }
To reproduce
src/app.lambdaHandler
src/app.lambdaHandler
Expected behavior I would expect the deployed Lambda to behave identically to when I run it locally.
Screenshots Screenshots of my local project layout, including the main handler and my local Lambda config are below...
Your Environment
Additional context