Closed kjetilge closed 4 years ago
This is fixed by #3928. We are planning to do a release that includes this change by the end of the week. Until the release is out, you can work around the issue by moving the index.js file that's in amplify/backend/function/<functionName>
to the src
folder.
It's not enough to just move that file because the whole package/zip/tree isn't being made properly, the dependencies are unavailable. This issue is not closed, this is a critical issue that prevents release. It affects other cognito trigger functions as well, such as post-confirmation
It's not cool to be closing issues until they are handled
Version 4.18.0 does not fix this
@djkmiles Sorry, you're right, you also need to move the package.json file into the src folder. Everything in the src folder will be zipped and uploaded to Lambda. #3928 above will fix the issue, but we ran into some other issues getting a release out last week so it's not available yet. I'll reopen until the release is complete
@djkmiles This should be fixed in the latest release (4.18.1). Feel free to reopen if you're still running into issues.
So I tried the same as above again today using amplify --version 4.19.0
amplify mock function funcnameAuthPreSignup
Provide the path.... src/event.json
Could not find ref for "modules". Using unsubstituted value.
Could not find ref for "DOMAINWHITELIST". Using unsubstituted value.
Could not find ref for "DOMAINBLACKLIST". Using unsubstituted value.
Starting execution...
ffba7AuthPreSignup failed with the following error:
{ code: 'MODULE_NOT_FOUND' }
Finished execution.
So It still does not work out-of-the-box.
Hi @kjetilge I believe that is a problem with mock and not with the lambda function itself. We are tracking the issue where environment variables are not loaded into mock correctly in #4085. Does the function work as expected when uploaded to Lambda via amplify push
?
Using amplify --version 4.20.0
it works when uploaded via Lambda push but not with mock.
I'm having a similar issue with PostConfirmation:
-> amplify mock function frontend3a437cf5PostConfirmation
Could not find ref for "modules". Using unsubstituted value.
Could not find ref for "GROUP". Using unsubstituted value.
frontend3a437cf5PostConfirmation failed with the following error:
{
type: 'Lambda:Unhandled',
message: "Cannot find module './modules'\n" +
'Require stack:\n' +
'- /home/boris/Documents/development/frontend/amplify/backend/function/frontend3a437cf5PostConfirmation/src/index.js\n' +
'- /home/boris/.nvm/versions/node/v12.14.0/lib/node_modules/@aws-amplify/cli/node_modules/amplify-nodejs-function-runtime-provider/lib/utils/execute.js'
}
Just tested this with Amplify 4.32.1 and seeing the same issue.
Tested in Amplify 4.40.0 and getting the same issue too
This issue has been automatically locked since there hasn't been any recent activity after it was closed. Please open a new issue for related bugs.
Looking for a help forum? We recommend joining the Amplify Community Discord server *-help
channels for those types of questions.
Describe the bug After adding the auth authPreSignup signup failes with error: CustomMessage failed with error index.handler is undefined or not exported. (In broeser)
When running amplify mock authPreSignup it failes with error:
CustomMessage failed with error index.handler is undefined or not exported.
Amplify CLI Version 4.18.0
To Reproduce
Expected behavior Both mocking and actual backend should just work
Screenshots If applicable, add screenshots to help explain your problem.
Desktop (please complete the following information):
Additional context If I add src/index.js, mockin works (using the code below). If I change authPreSignup/index.js to:
Then it works. I've also succeded with exporting "custom" in env, but don't remember exactly how.
In total this is not a good developer experience. It feels like a bug.