I am using AppSync with Aurora/RDS. I would like that in some cases, when a query/mutation is sent to the db, then, after that, I want to send an email and push notification, but this should be detached from the query/mutation, that is, it does not matter if it fails or works. At the moment I see all these options: Can you tell me which one I should use?
Create a query that calls a lambda function that sends the push/email and call it from the client once the actual query/mutation is done. I don't like this because the logic is in the client rather than the server. Seems easy to implement, and I guess it is easy to ignore the result of the second operation from a client point of view.
A variation of the previous one. Pack both operations in a single network request. With GraphQL, that is easy, but I don't want the client waits for the second operation. (Is it possible to create lambda functions that return immediately, like a trigger of other functions?)
Attach my queries/mutations to lambda functions instead of RDS directly. Then, those lambda functions call other lambda functions for notifications. Seems more difficult to program, but more micro-services architecture friendly. Probably this is the best one, not sure.
Use SQL triggers and call lambda functions from those triggers. I don't know if this is even possible. Researching...
Use pipelines resolvers. The first one is the query/mutation, the second one is the lambda function that sends the push/email. I would say this is a bad option because I don't want the client to wait for the second operation or manage the logic when the second resolver fails.
Amazon RDS Events: It appears it is possible to attach lambda functions to specific AWS RDS events. https://docs.aws.amazon.com/lambda/latest/dg/services-rds.html It seems it is about creating DBs, restoring... and that kind of things. I don't see anything like creating a row, updating a row... So, I discard this unless I am wrong.
Invoking a Lambda Function with an Aurora MySQL Stored Procedure CALL mysql.lambda_async ( lambda_function_ARN,lambda_function_input ) https://docs.aws.amazon.com/AmazonRDS/latest/AuroraUserGuide/AuroraMySQL.Integrating.Lambda.html "For example, you might want to send a notification using Amazon Simple Notification Service (Amazon SNS) whenever a row is inserted into a specific table in your database." That is exactly what I am looking for. I like this idea, but I don't know if that is possible with Aurora Serverless. Researching... It seems it is not possible when using server-less: https://www.reddit.com/r/aws/comments/a9szid/aurora_serverless_call_lambda/
Use step functions: No idea about how to use it.
Somehow, attach this lambda notification function to GraphQL/AppSync instead of the database, but I guess it is not a good idea because I need to read the database to the push notification token and the email of the use who is going to receive the notifications.
Which method do you recommend me? I am using amplify cli. Thanks a lot.