title: AWS Lambda - Error: unable to get local issuer certificate
body: <p>I am trying to connect to an amazon postgreSQL RDS using a NodeJS lambda. </p>
  
  <p>The lambda is in the same VPC as the RDS instance and as far as I can tell the security groups are set up to give the lambda access to the RDS. The lambda is called through API gateway and I'm using knex js as a query builder. When the lambda attempts to connect to the database it throws an "unable to get local issuer certificate" error, but the connection parameters are what I expect them to be.</p>
  
  <p>I know this connection is possible as I've already implemented it in a different environment, without receiving the certificate issue. I've compared the two environments but cannot find any immediate differences.</p>
  
  <p>The connection code looks like this:</p>
  
  <pre><code>import AWS from 'aws-sdk';
  import { types } from 'pg';
  import { Moment } from 'moment';
  import knex from 'knex';
  
  const TIMESTAMP_OID = 1114;
  // Example value string: "2018-10-04 12:30:21.199"
  types.setTypeParser(TIMESTAMP_OID, (value) =&gt; value &amp;&amp; new Date(`${value}+00`));
  
  export default class Database {
    /**
     * Gets the connection information through AWS Secrets Manager
     */
    static getConnection = async () =&gt; {
      const client = new AWS.SecretsManager({
        region: '&lt;region&gt;',
      });
  
      if (process.env.databaseSecret == null) {
        throw 'Database secret not defined';
      }
  
      const response = await client
        .getSecretValue({ SecretId: process.env.databaseSecret })
        .promise();
  
      if (response.SecretString == undefined) {
        throw 'Cannot find secret string';
      }
  
      return JSON.parse(response.SecretString);
    };
  
    static knexConnection = knex({
      client: 'postgres',
      connection: async () =&gt; {
        const secret = await Database.getConnection();
  
        return {
          host: secret.host,
          port: secret.port,
          user: secret.username,
          password: secret.password,
          database: secret.dbname,
          ssl: true,
        };
      },
  });
  }
  </code></pre>
  
  <p>Any guidance on how to solve this issue or even where to start looking would be greatly appreciated. </p>