将记录写入 Aurora 数据库实例时触发 AWS Lambda

AWS Lambda triggered when a record is written into Aurora DB instance

如何创建在记录插入到 Aurora 数据库实例的 table 时触发的 AWS Lambda?

我不知道如何将 Lambda 关联到它。

当我在网上搜索时,Lambda 主要触发到 S3 或 DynamoDB 事件等

如您所说,DynamoDB、S3 和其他服务可以与 Lambda 原生集成,但没有原生 Aurora 集成。

无论何时向数据库中插入内容,您都可以从应用程序写入 Kinesis 流,但事件顺序会有问题,因为 Kinesis 不参与数据库事务。

您还可以将所有写入请求发送到 Kinesis,然后通过 Lambda 函数将它们插入到您的 Aurora 数据库中,从而消除排序问题。但是您将需要一种事件溯源/CQRS 方法来为您的数据建模。

这里是the list of supported event sources. If you want to keep it simple, invoke the Lambda function from the application that inserts data into Aurora, but only after the database transaction is successfully committed. There's likely an AWS SDK for whatever language your application is written in. For example, here's docs on the Lambda API for Javascript

您在 Amazon Aurora 数据库中创建的存储过程现在可以调用 AWS Lambda 函数。

这是一个全新的功能...http://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/Aurora.Lambda.html

根据 2020 年 12 月的最新更新,现在即使使用 Aurora (PostreSQL) 也是可能的

此处提供指南 - https://docs.aws.amazon.com/AmazonRDS/latest/AuroraUserGuide/PostgreSQL-Lambda.html

Amazon Aurora (PostgreSQL) 触发 lambda - https://aws.amazon.com/about-aws/whats-new/2020/12/amazon-aurora-postgresql-integrates-with-aws-lambda/ (11.December.2020)

Amazon RDS (PostgreSQL) 触发器到 lambda - https://aws.amazon.com/about-aws/whats-new/2021/04/amazon-rds-postgresql-integrates-aws-lambda/ (14.April.2021)