Describe the bug
amplifyXXXXXXPostConfirmation
Lambda index.js
and event.js
generated in incorrect directory.Auth.confirmSignUp
aws-amplify APIPostConfirmation failed with error index.handler is undefined or not exported.
Amplify CLI Version
4.17.2
To Reproduce
amplify auth update
What do you want to do?
Walkthrough all the auth configurations
Select the authentication/authorization services that you want to use:
User Sign-Up, Sign-In, connected with AWS IAM controls (Enables per-user Storage features for images or other content, Analytics, and more)
Allow unauthenticated logins? (Provides scoped down permissions that you can control via AWS IAM)
Yes
Do you want to enable 3rd party authentication providers in your identity pool?
No
Do you want to add User Pool Groups?
No
Do you want to add an admin queries API?
No
Multifactor authentication (MFA) user login options:
OFF
Email based user registration/forgot password:
Enabled (Requires per-user email entry at registration)
Please specify an email verification subject:
Your verification code
Please specify an email verification message:
Your verification code is {####}
Do you want to override the default password policy for this User Pool?
No
Specify the app's refresh token expiration period (in days):
30
Do you want to specify the user attributes this app can read and write?
No
Do you want to enable any of the following capabilities?
Do you want to use an OAuth flow?
No
? Do you want to configure Lambda Triggers for Cognito?
Yes
? Which triggers do you want to enable for Cognito
Post Confirmation
? What functionality do you want to use for Post Confirmation
Create your own module
Auth.signUp
aws-amplify APIExpected behavior
amplifyXXXXXXPostConfirmation
Lambda index.js
and event.js
generated in src
directory.Auth.confirmSignUp
aws-amplify APIScreenshots
Desktop (please complete the following information):
Hi same here.
amplify function invoke <function>
gives
Error: ENOENT: no such file or directory, open 'amplify/backend/function/apiPostConfirmation/src/event.json'
It seems that the lib is looking for event.json
and index.js
inside the src directory
EDIT:
If you move the files accordingly to the following
-- add-to-group.js
-- event.json
-- index.js
-- package.json
-- package-lock.json
and alter the index.js function to your needs. For my use case it was like:
exports.handler = (event, context, callback) => {
const { handler } = require('./add-to-group')
handler(event, context, callback)
}
Closing as a duplicate of https://github.com/aws-amplify/amplify-cli/issues/3823
This is fixed by version 4.18.0
@regenrek please try amplify mock function <yourFunction>
after updating your CLI
Feel free to comment if this doesn't resolve your issue.
Closing as a duplicate of #3823
This is fixed by version 4.18.0
@regenrek please tryamplify mock function <yourFunction>
after updating your CLI
Feel free to comment if this doesn't resolve your issue.
I don't understand what exactly was fixed in 4.18.0 - local invocation or the original problem that "PostConfirmation failed with error index.handler is undefined or not exported." ?
Could you please clarify? I'm still experiencing this problem with index.handler is undefined with 4.18.0.
Amplify version 4.18.0 does not fix the problem.
I am using amplify version 4.18.0 and I am having the same problem.
All codes (except add-to-group.js) are outside of src directory. If I move the files (index.js, package.json, package-lock.json and node-modules) into the src directory it works. However, if I further update the lambda function by adding the permission to access another DynamoDB I got "RangeError: Maximum call stack size exceeded".
{
"errorType": "RangeError",
"errorMessage": "Maximum call stack size exceeded",
"stack": [
"RangeError: Maximum call stack size exceeded",
" at Object.hasOwnProperty (
" at Function.NativeModule.exists (internal/bootstrap/loaders.js:199:33)",
" at Function.NativeModule.nonInternalExists (internal/bootstrap/loaders.js:217:27)",
" at Function.Module._resolveLookupPaths (internal/modules/cjs/loader.js:456:20)",
" at Function.Module._resolveFilename (internal/modules/cjs/loader.js:629:20)",
" at Function.Module._load (internal/modules/cjs/loader.js:562:25)",
" at Module.require (internal/modules/cjs/loader.js:692:17)",
" at require (internal/modules/cjs/helpers.js:25:18)",
" at exports.handler (/var/task/index.js:10:25)",
" at exports.handler (/var/task/index.js:11:5)"
]
}
@jingxizhang I upgraded to 4.18.1 and it fixed the problem. But I had to do one trick because when I just ran amplify auth update
again hoping to just refresh my add to groups function, it didn't fix the file structure. What I had to do is this:
amplify auth update
amplify auth update
again and chose to create add to group function.Hope this helps.
@spyboost Thank you. I confirm that version 4.18.1 fixes the problem of placing files generated outside of src folder. However, I still get "RangeError: Maximum call stack size exceeded" after I updated the postComfirm lambda function by adding permission to another DynamoDB. I reported it separatedly (#4065).
Most helpful comment
@jingxizhang I upgraded to 4.18.1 and it fixed the problem. But I had to do one trick because when I just ran
amplify auth update
again hoping to just refresh my add to groups function, it didn't fix the file structure. What I had to do is this:amplify auth update
amplify auth update
again and chose to create add to group function.Hope this helps.