Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

RDS Service Triggering Lambda

I am new to AWS and I was looking for a way to trigger Lambda from RDS Service in particular MYSql. Is there any way possible to achieve it? If not is there any other way to achieve the same?

like image 268
Roopesh Kumar Avatar asked Nov 29 '15 09:11

Roopesh Kumar


People also ask

Can SES trigger Lambda?

When you use Amazon SES to receive messages, you can configure Amazon SES to call your Lambda function when messages arrive. The service can then invoke your Lambda function by passing in the incoming email event, which in reality is an Amazon SES message in an Amazon SNS event, as a parameter.

Can RDS trigger Lambda?

You can use AWS Lambda to process event notifications from an Amazon Relational Database Service (Amazon RDS) database. Amazon RDS sends notifications to an Amazon Simple Notification Service (Amazon SNS) topic, which you can configure to invoke a Lambda function.


Video Answer


3 Answers

There are now multiple ways to trigger Lambda from both AWS RDS and AWS MySQL, but support varies between DB engines. Please see below edited section of this answer if you are actually curious about RDS Event messages processed by AWS Lambda.


EDIT: If you are looking for a way for AWS Lambda to respond to Event messages emitted by AWS RDS (about the state of the cluster and not DB data events), please read these docs. NOTE: Again, this has nothing to do with AWS Lambda invocation & responding to data manipulation events on DB tables/records.

like image 170
garnaat Avatar answered Oct 19 '22 00:10

garnaat


If you're using AWS Aurora, you can invoke an AWS Lambda function from by calling the mysql.lambda_async procedure.

Example:

CALL mysql.lambda_async (
  lambda_function_ARN,
  lambda_function_input
)

lambda_function_ARN

The Amazon Resource Name (ARN) of the Lambda function to invoke.

lambda_function_input

The input string, in JSON format, for the invoked Lambda function.

EDIT: More details available here: Invoking a Lambda function from an Amazon Aurora MySQL DB cluster

like image 8
Jim Geurts Avatar answered Oct 19 '22 01:10

Jim Geurts


As of March 15th 2022, you can invoke an AWS Lambda function only from PostgreSQL engine in RDS but not from MySQL engine. The documentation is provided below:

  1. Invoking an AWS Lambda function from an RDS for PostgreSQL DB instance

You can also invoke an AWS Lambda function from either MySQL or PostgreSQL engines in Aurora (NOTE: Aurora is different AWS service from RDS). The documentation for both is provided below:

  1. Invoking an AWS Lambda function from an Aurora PostgreSQL DB cluster
  2. Invoking a Lambda function from an Amazon Aurora MySQL DB cluster
like image 6
Desha Avatar answered Oct 19 '22 00:10

Desha