Describe the bug
I added a Pre Token Generation Lambda trigger by running the amplify update auth command. I successfully pushed this change to the cloud, but sign in for my app no longer works. I inspected the logs of the newly added trigger and found this error:
{
"errorType": "Runtime.HandlerNotFound",
"errorMessage": "index.handler is undefined or not exported",
"stack": [
"Runtime.HandlerNotFound: index.handler is undefined or not exported",
" at Object.module.exports.load (/var/runtime/UserFunction.js:144:11)",
" at Object.<anonymous> (/var/runtime/index.js:45:30)",
" at Module._compile (internal/modules/cjs/loader.js:778:30)",
" at Object.Module._extensions..js (internal/modules/cjs/loader.js:789:10)",
" at Module.load (internal/modules/cjs/loader.js:653:32)",
" at tryModuleLoad (internal/modules/cjs/loader.js:593:12)",
" at Function.Module._load (internal/modules/cjs/loader.js:585:3)",
" at Function.Module.runMain (internal/modules/cjs/loader.js:831:12)",
" at startup (internal/bootstrap/node.js:283:19)",
" at bootstrapNodeJSCore (internal/bootstrap/node.js:623:3)"
]
}
I think it's caused by the fact that only the src/custom.js or in this case src/alter-claims.js gets added to the zip build of the Lambda function. The index.js (which contains the handler function that iterates over the different modules) is never uploaded to the cloud.
When executing the Lambda it can't find index.handler since it never got uploaded.
Amplify CLI Version
4.18.0
To Reproduce
amplify update authExpected behavior
I expect the Lambda trigger generated by amplify to execute properly.
Desktop:
@mdoesburg does manually moving the index.js file to the source folder and doing a push fix the problem?
@mdoesburg does manually moving the index.js file to the source folder and doing a push fix the problem?
@nikhname Thanks for the fix! I can confirm this works now.
Most helpful comment
@mdoesburg does manually moving the index.js file to the source folder and doing a push fix the problem?