2

How do I create an AWS Lambda that triggers when a record is inserted into a table of an Aurora DB instance?

I do not know how to associate the Lambda to it.

When I searched on the net, the Lambda mostly triggered to a S3 or a DynamoDB events etc.

4 Answers 4

6

The stored procedures that you create within your Amazon Aurora databases can now invoke AWS Lambda functions.

This is a brand new feature... http://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/Aurora.Lambda.html

Sign up to request clarification or add additional context in comments.

1 Comment

AFAIK this is valid only for MySQL
1

As you said, DynamoDB, S3, and other services can be natively integrated with Lambda but there is no native Aurora integration.

You could write to a Kinesis stream from your application whenever you insert something into your database but you will have problems with the order of the events because Kinesis does not participate in the database transaction.

You could also send all write request to Kinesis and insert them into your Aurora database from a Lambda function to get rid of the ordering issue. But you will need an Event Sourcing / CQRS approach to model your data.

2 Comments

thanks it makes sense now. What I would really like to do is to get some data from a on premise database when something is written into Aurora and update it to the same record. How should I go about it if Lambda does not seem like a good solution?
Aurora can invoke Lambda functions now. docs.aws.amazon.com/AmazonRDS/latest/UserGuide/…
1

Here's 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.

Comments

0

It is possible now even with Aurora (PostreSQL) as per latest updates from December 2020

Guide is available here - https://docs.aws.amazon.com/AmazonRDS/latest/AuroraUserGuide/PostgreSQL-Lambda.html

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

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.