Unrecognizable Lambda Output Cognito

As shown in the PreSignUp trigger example in Cognito developer guide, you should use context.done(null, event); or context.succeed(event); at the end of your trigger.

Cognito expects the complete event source back in response from your lambda triggers being invoked as part of different Cognito User Pools flows.


Ruby lambda people, all cognito wants back is the event object.

def lambda_handler(event:, context:)
    # TODO implement
    return event
end

Is very simple.

  1. Create a Lambda Function with this code : example

    exports.handler = function(event, context) {
    
    /* This Lambda function returns a flag to indicate if a user should be auto-confirmed.
    Perform any necessary validations.Impose a condition that the minimum length of the
    username of 5 is imposed on all user pools. */
    
       if (event.userName.length < 5) {
          var error = new Error('failed!');
          context.done(error, event);
       }
    
    /* Access your resource which contains the list of emails of users who were invited to
    sign up. Compare the list of email IDs from the request to the approved list */
    
       if(event.userPoolId === "yourSpecialUserPool") {
          if (event.request.userAttributes.email in listOfEmailsInvited) {
               event.response.autoConfirmUser = true;
          }
       }
    
       // Return result to Cognito
       context.done(null, event);
    };
    

Note: Role: Lambda basic execution

  1. Create the trigger from cognito console and select the function lambda.

TEST 3. Create the user with the API and DONE.