DEV Community

Cover image for Confirm AWS Cognito signups automatically

Confirm AWS Cognito signups automatically

kevin_odongo35 profile image Kevin Odongo ・1 min read

Hey Devs

How has been your week? In today's tutorial, I will share how to automatically confirm users in your application without sending the confirmation code.

When users signup in for your application normally you will send a confirmation code in their email or phone to confirm their account.

This tutorial will be helpful if you are using AWS Cognito. Assuming you want to auto-confirm your user's email and phone numbers. This can be done using a Lambda function.


  • Create a Lambda function name it confirmSignUp. For this tutorial, I will use node runtime.

  • Copy the following and paste it in the index.js file.

exports.handler = (event, context, callback) => {

    // Confirm the user
        event.response.autoConfirmUser = true;

    // Set the email as verified if it is in the request
    if (event.request.userAttributes.hasOwnProperty("email")) {
        event.response.autoVerifyEmail = true;

    // Set the phone number as verified if it is in the request
    if (event.request.userAttributes.hasOwnProperty("phone_number")) {
        event.response.autoVerifyPhone = true;

    // Return to Amazon Cognito
    callback(null, event);

Enter fullscreen mode Exit fullscreen mode
  • Save the Lambda function and go back to AWS Cognito dashboard. select triggers.
    Alt Text

  • Finally in the Pre sign-up select your Lambda function and save.
    Alt Text

Funny thing that is all you have to do to auto-confirm user emails and passwords when they signup to your application.

Thank you.

Discussion (0)

Editor guide