title: AWS Cognito node lambda migration user : authenticateUser is not defined
body: <p>I would like to migrate users from userPool 1 to userPool 2 with the migration user lambda in AWS Console function. In order to do it, I have used the script provided by AWS but I can't find how I can use authenticateUser for instance. It is not defined when executed. </p>
  
  <p>The migration lambda is executed.
  authenticateUser is not defined</p>
  
  <p>I have also tried to create a layer, imported succesfully and set the layer in my lambda function but cannot make it work too.</p>
  
  <pre class="lang-js prettyprint-override"><code>exports.handler = (event, context, callback) =&gt; {
  
      var user;
  
      if ( event.triggerSource == "UserMigration_Authentication" ) {
  
          // authenticate the user with your existing user directory service
          user = authenticateUser(event.userName, event.request.password);
          if ( user ) {
              event.response.userAttributes = {
                  "email": user.emailAddress,
                  "email_verified": "true"
              };
              event.response.finalUserStatus = "CONFIRMED";
              event.response.messageAction = "SUPPRESS";
              context.succeed(event);
          }
          else {
              // Return error to Amazon Cognito
              callback("Bad password");
          }
      }
      else if ( event.triggerSource == "UserMigration_ForgotPassword" ) {
  
          // Lookup the user in your existing user directory service
          user = lookupUser(event.userName);
          if ( user ) {
              event.response.userAttributes = {
                  "email": user.emailAddress,
                  // required to enable password-reset code to be sent to user
                  "email_verified": "true"  
              };
              event.response.messageAction = "SUPPRESS";
              context.succeed(event);
          }
          else {
              // Return error to Amazon Cognito
              callback("Bad password");
          }
      }
      else { 
          // Return error to Amazon Cognito
          callback("Bad triggerSource " + event.triggerSource);
      }
  };
  </code></pre>
  
  <p>authenticateUser is not defined</p>
  
  <p>My question is : how do we import this function ? </p>
  
  <p>Thanks a lot.</p>