generated trigger lambda missing callback
See original GitHub issueNote: If your issue/bug is regarding the AWS Amplify Console service, please log it in the Amplify Console GitHub Issue Tracker
Describe the bug
I went back and used amplify auth update
to generate a Post Auth trigger for my user pool since some how manually selecting it was lost. (would be nice to be able to provide names for trigger lambdas) and I noticed the generated code is slightly different than what I see from amplify function add
. It generates a custom.js
for my code and has other code in index.js
for looking for a MODULES env var. I left if that way and copied my code from the lambda I was using prior to it being unselected into custom.js
and push it up. After if completed the build I tried logging in and I was seeing a InvalidLambdaResponseException
I went back and noticed that the generated index.js
did not include calling callback(null, event)
. After I added that and pushed/let it build and tried again I was able to log in.
After adding the callback line the code looks like:
/*
this file will loop through all js modules which are uploaded to the lambda resource,
provided that the file names (without extension) are included in the "MODULES" env variable.
"MODULES" is a comma-delimited string.
*/
exports.handler = (event, context, callback) => {
const modules = process.env.MODULES.split(',')
for (let i = 0; i < modules.length; i += 1) {
const { handler } = require(`./${modules[i]}`)
handler(event, context, callback)
}
callback(null, event) // this line was missing
Amplify CLI Version 4.20.0
Also I’m curious if that is the direction the functions generated by amplify function add
are heading, will they use a custom.js
by default?
Issue Analytics
- State:
- Created 3 years ago
- Reactions:2
- Comments:11 (2 by maintainers)
@cyrfer Thanks for your input, I reopen the issue and marking as a docs enhancement to clear up the confusion around the implementation.
It was unexpected to to me see the
custom.js
also. I’m may delete it, but I would also like to know the thoughts behind it.