question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

PostConfirmation failed with error index.handler is undefined or not exported.

See original GitHub issue

Describe the bug

  • amplifyXXXXXXPostConfirmation Lambda index.js and event.js generated in incorrect directory.
  • Error occured when call Auth.confirmSignUp aws-amplify API
PostConfirmation failed with error index.handler is undefined or not exported.

Amplify CLI Version 4.17.2

To Reproduce

  1. 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
  1. call Auth.signUp aws-amplify API

Expected behavior

  • amplifyXXXXXXPostConfirmation Lambda index.js and event.js generated in src directory.
  • Success call Auth.confirmSignUp aws-amplify API

Screenshots image

Desktop (please complete the following information):

  • OS: [Ubuntu]
  • Node Version. [v12.14.1]

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:7 (1 by maintainers)

github_iconTop GitHub Comments

4reactions
spyboostcommented, Apr 24, 2020

@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:

  1. Run amplify auth update
  2. When it asked if I want to generate all those post functions I unselected everything.
  3. After auth update is done it removed my function.
  4. Run amplify auth update again and chose to create add to group function.
  5. Now it generated correct directory and file structure.

Hope this helps.

2reactions
regenrekcommented, Apr 4, 2020

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

src
-- 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)
}
Read more comments on GitHub >

github_iconTop Results From Across the Web

aws lambda - Index handler is undefined or not exported
I have a lambda function which was working fine but I wanted to import a package so I created a directory with index.js...
Read more >
AWS Lambda + Node: index.handler is not defined
If you get an “index.handler is undefined” error on AWS lambda, it could be one of a couple things – essentially their code...
Read more >
AWS Lambda function errors in Node.js
This page describes how to view Lambda function invocation errors for the Node.js runtime using the Lambda console and the AWS CLI.
Read more >
Lambdaでindex.handler is undefined or not exportedが出た時 ...
Copied! index.handler is undefined or not exported. 対処法. 以下の2つを実施した。
Read more >
Lambda returning Runtime.HandlerNotFound error - not sure ...
HandlerNotFound: index.handler is undefined or not exported", " at Object.module.exports.load (/var/runtime/UserFunction.js:144:11)", ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found