NodeJS executing multiple database queries using async library
A couple of helper functions will aid in flattening your callback chain:
function getConnection() {
  return new Promise((res, rej) =&gt; {
    pool.getConnection(function (err, connection) {
      if (err) {
        rej(err);
      } else {
        res(connection);
      }
    });
  });
}

function query(connection, sql, params) {
  return new Promise((res, rej) =&gt; {
    connection.query(sql, params, function (err, rows) {
      if (err) {
        rej(err);
      } else {
        res(rows);
      }
    });
  });
}

Then you can do something like:
async function step_1(connection) {
  const rows = await query(connection, 'step 1 query');
  return rows.insertId;
}

function step_2(connection, id) {
  return query(connection, 'step 2 query', id);
}

function step_3(connection, id, result) {
  return query(connection, 'step 3 query', id, result);
}

exports.handler = async (event) =&gt; {
  const connection = await getConnection();
  try {
    const id = await step_1(connection);
    const rows = await step_2(connection, id);
    const result = await step_3(connection, id, rows);
    return JSON.stringify(result);
  } finally {
    connection.release();
  }
};