skip to Main Content

I am trying to make it so that when a user signs up on my application and confirms their account, that it updates the user mysql database on cpanel. I found that you can use AWS AWS RDS to create a database instance, however it is pretty pricey to use.

Is there a cheaper alternative to insert rows in my remote database through an AWS lambda trigger.

2

Answers


  1. I think you can create lambda function in AWS which will act like api(web hook) for your application.

    Login or Signup to reply.
  2. You can use cognito lambda triggers to invoke lambda function.
    Cognito lambda triggers support multiple events such as user sign-up and sign-in.

    Since you want to trigger the lambda after the user successfully signs up, you can use the Post confirmation Lambda trigger

    Post confirmation Lambda trigger - Adds custom welcome messages or event logging for custom analytics
    

    Similar to the example provided in the doc, we can do the same to insert user data into a database.

    exports.handler = (event, context, callback) => {
      console.log(event);
    
      if (event.request.userAttributes.email) {
        insertIntoDatabase(event.request.userAttributes.email, function (status) {
          // Return to Amazon Cognito
          callback(null, event);
        });
      } else {
        // Nothing to do, the user's email ID is unknown
        callback(null, event);
      }
    };
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search