ellipse-of-uncertainty
ellipse-of-uncertainty

Reputation: 1035

How to enable lambda_sync/lambda_async functions in Aurora

When I attempt to grant the INVOKE LAMBDA privileges on my user it fails with a syntax error:

mysql> GRANT INVOKE LAMBDA ON mydb.* TO 'myuser'@'myaddress';
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'INVOKE LAMBDA ON mydb.* TO 'myuser'@'myaddress'' at line 1

The lambda_sync and lambda_async functions are also not defined:

mysql> select lambda_sync("arn:aws:lambda:ap-southeast-1:xxxxxxxxxxx:function:MyLambda", '{"operation":"ping"}');
ERROR 1305 (42000): FUNCTION mydb.lambda_sync does not exist

I've also tried using mysql.lambda_sync/mysql.lambda_async here.

According to the docs, these functions should be native to my version of aurora.

You can call the native functions lambda_sync and lambda_async when you use Aurora MySQL version 1.16 and later.

mysql> select AURORA_VERSION();
+------------------+
| AURORA_VERSION() |
+------------------+
| 2.01.1           |
+------------------+
1 row in set (0.10 sec)

The lambda_sync and lambda_async functions are built-in, native functions that invoke a Lambda function synchronously or asynchronously.

I've gone through the documentation, created an aurora instance using mysql 5.7 compatibility, creating a role on my db cluster with the lambda invoke permissions, and done half a dozen other things suggested in the docs. What am I missing?

Upvotes: 4

Views: 6162

Answers (4)

tfrancois
tfrancois

Reputation: 173

As of 5/16/2020, I am running on AWS Aurora MySQL 2.07.2 and I can confirm that it finally appears as if the lambda_async and lambda_sync native functions are enabled and working. They might have recently been silently enabled by Amazon but not publicly announced. Can anyone else confirm the same?

Upvotes: 0

kirilclicks
kirilclicks

Reputation: 1677

Try allowing mysql.lambda_sync / mysql.lambda_async to your user(s):

GRANT EXECUTE ON PROCEDURE mysql.lambda_async TO 'your_user'@'%'

Upvotes: 2

tfrancois
tfrancois

Reputation: 173

I am running an instance of AWS Aurora 2.02.2 and although the native Lambda invocation functions are still not yet available, it DOES have support for the mysql.lambda_async stored procedure call using

CALL mysql.lambda_async('<<<<< AWS LAMBDA ARN GOES HERE >>>>>>', options);

And using this stored procedure did not require the explicit GRANT INVOKE LAMBDA privilege to run it. It worked out of the box for me once I correctly setup the IAM roles necessary in AWS for RDS to access my lambda function.

Where options in the call above is a JSON object with the parameters you want passed into the function, received by the event parameter in the Node.JS 8.10 handler function.

Hope this is helpful for those who need that functionality now. Hopefully AWS ports support for the native functions in the near future, but until then this works fine for me.

Upvotes: 2

Michael - sqlbot
Michael - sqlbot

Reputation: 178974

Currently, Aurora MySQL 2.01 does not support features added in Aurora MySQL version 1.16 and later.

https://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/AuroraMySQL.Updates.20180206.html

Aurora/MySQL 2.x is not a "later" version than Aurora/MySQL 1.x... they're two different release families. The native Lambda invocation functions are not available in 2.x (yet).

Upvotes: 6

Related Questions