title: Not able to connect node js express API deployed on AWS Lamda to AWS RDS(My SQL)
body: <p>I deployed my node js express application on AWS Lamda and I am able to hit my API router method like get ,post etc .. but when I try to fetch data from amazon RDS it is returning 502 error in browser console and  without DB call the API returns hard-coded response well.
  I tried to connect my API at initial stage and used following code </p>
  
  <pre><code>var mysql = require('mysql');
      var pool = mysql.createPool({
      host: 'rds end point',
      user: 'xxxx',
      password: 'xxxx',
      database: 'TestDb'
  });
  
  exports.handler = (event, context,callback) =&gt; { 
      context.callbackWaitForEmptyEventLoop=false;
      pool.getConnection(function(err,connection) {
          connection.query("select count(*) as count from Classes", function(error,result,fields) {
              connection.release();
              if(error) callback(error);
              else callback(null,result[0].count)
          })
      })
  }
  </code></pre>
  
  <p>and at the LAMDA Console log I am getting below error instead of count</p>
  
  <blockquote>
    <p>"errorMessage": "2019-04-04T12:06:39.020Z 7ffa5ee4-4000-4254-82fc-27617eb9975a Task timed out after 5.01 seconds"</p>
  </blockquote>
  
  <p>any one help me on this issue ?</p>