Lambda 函数中从不调用与 Sequelize 的 RDS 连接

RDS connection with Sequelize is never called in Lambda function

我将 AWS AppSync 与 Lambda 函数一起用作解析器。 这些函数查询 RDS Postgres 数据库(使用 Sequelize)。

我的问题是,无论我做什么,都会触发 none 个查询。我的代码有什么问题?

import { Context, Callback } from 'aws-lambda';
import * as Sequelize from 'sequelize';

const sequelize = new Sequelize({
  database: process.env.RDS_NAME,
  username: process.env.RDS_USERNAME,
  password: process.env.RDS_PASSWORD,
  host: process.env.RDS_HOST,
  port: 5432,
  dialect: 'postgres',
  pool: { idle: 1000, max: 1 }
});

const options = {
  timestamps: false,
  freezeTableName: true
};

const Node = sequelize.define(
  'node',
  {
    nodeId: {
      type: Sequelize.INTEGER,
      primaryKey: true,
      autoIncrement: true
    },
    slug: {
      type: Sequelize.STRING
    }
  },
  options
);

export const getUser = async (
  event: any,
  context: Context,
  callback: Callback
) => {
  context.callbackWaitsForEmptyEventLoop = false;

  Node.findAll({
    where: {}
  })
    .then(nodes => {
      console.log('nodes', nodes);
      callback(null, {
        id: 1,
        name: JSON.stringify(nodes)
      });
    })
    .catch(err => callback(err));
};

我看过这个 post 但没有成功。

我发现了问题。我的 RDS 位于与默认安全组不同的安全组中。我必须对其进行更改才能使其正常工作。