title: AWS lambda api Postgres not won’t insert
body: <p>I have the following AWS lambda handler:</p>
  <pre><code>exports.handler = async (event, data) =&gt; {
    var AWS = require('aws-sdk/global');
    const awsParamStore = require('aws-param-store');
    const {
      Pool
    } = require('pg');
    var host;
  
  
    await awsParamStore.getParameter('testing-main-rds-url', { //get database host from AWS
        region: 'us-east-1'
      })
      .then((parameter) =&gt; {
        host = parameter.Value
      });
  
    var signer = await new AWS.RDS.Signer({
      region: 'us-east-1',
      username: 'developer',
      hostname: host,
      port: 5432
    });
  
    var token = await signer.getAuthToken({}); //get token from AWS
  
  
    const db = await new Pool({
      user: &quot;developer&quot;,
      host: host,
      database: &quot;main&quot;,
      password: token,
      port: 5432,
      ssl: true,
    });
  
  
    const query = `INSERT INTO crm.user_crm
     (u_id,username)
     VALUES ($1,$2)`;
    const values = [event.u_id, event.username];
  
  
  db.connect((err, client, release) =&gt; {
    if (err) {
      throw(&quot;Error acquiring client.&quot;, err.stack);
    } else {
      client.query(query, values, (err, result) =&gt; {
        release();
        if (err) {
          throw(&quot;Error executing query.&quot;, err.stack);
          return ;
        } else {
          console.log(&quot;INSERT DONE&quot;);
          db.end()
          return {
              statusCode: 200
          };
        }
      })
    }
  })
  };
  </code></pre>
  <p>This code will take in data and add it to a database.
  When I run it on my computer with <code>console.log(require('./index').handler(data));</code> it works perfectly and inserts the record. When I run it from lambda it returns nothing and doesn’t insert a record. Any help would be appreciated.</p>