Kukka
Kukka

Reputation: 43

Is it possible to use MySQL UDF on Amazon RDS?

I need to send an HTTP request when a database changes, so I am using the mysqludf extension.

It works locally, but how can I get it working on Amazon RDS too? If it's not possible, I need a solution to use a MySQL trigger together with the sys_exec function or something similar.

Can someone can help me?

Thanks!

Upvotes: 4

Views: 4366

Answers (4)

Nunchi
Nunchi

Reputation: 11

Amazon RDS does not provide shell access to DB instances, and restricts access to certain system procedures and tables that require advanced privileges. However, 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[1]. You can also invoke an AWS Lambda function from an Aurora MySQL DB cluster by calling the mysql.lambda_async procedure [2]. Starting in Aurora MySQL version 1.8 and Aurora MySQL version 2.06, you can use the native function method instead of these stored procedures to invoke a Lambda function [3].

[1] https://docs.aws.amazon.com/lambda/latest/dg/services-rds.html
[2] https://docs.aws.amazon.com/AmazonRDS/latest/AuroraUserGuide/AuroraMySQL.Integrating.Lambda.html
[3] https://docs.aws.amazon.com/AmazonRDS/latest/AuroraUserGuide/Aurora.Integrating.html

Upvotes: 0

Kragh
Kragh

Reputation: 320

There is not a way to do what you want, in RDS.

It is not possible to use UDF but there is more elegant way to satisfy your needs.

MySQL trigger function running on AWS Aurora can call AWS Lambda function. That function can do anything you want - call REST API, publish a message to SQS, whatever.

https://aws.amazon.com/blogs/database/capturing-data-changes-in-amazon-aurora-using-aws-lambda/

And yes, I'm very late to the party but I'm posting this solution for random googlers like me :)

Upvotes: 1

sebin vincent
sebin vincent

Reputation: 328

If your final requirement is to call some external API by taking a trigger from some sql operation on RDS database, you can leverage AWS SNS and lambda to achieve this. Its not a straight road,but will serve the purpose. In fact I have used this workaround to meet one of my requirement. You can find the thread here.

Upvotes: 1

Michael - sqlbot
Michael - sqlbot

Reputation: 179074

Definitely not. RDS instances are locked down in two ways that prevent you from installing UDFs; not to be confused with a stored functions, UDFs are written in C and compiled. The binary shared object file then has to be copied to the filesystem of the MySQL Server, which is not accessible to you with RDS (that's one) and you have to have the SUPER privilege to actually load the UDF plugin from the file, which RDS does not provide (that's two).

Additionally, you can't use sys_exec() or sys_eval() on RDS, because those functions aren't built-in. They're UDF plugins, too.

This is one of the tradeoffs with RDS (or any "managed" database server service, I suspect). In exchange for simplicity and point & click provisioning, there are some things that you give up.

There is not a way to do what you want, in RDS.

Upvotes: 12

Related Questions