Skip to content

Instantly share code, notes, and snippets.

@alexcasalboni
Created June 18, 2019 09:56
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save alexcasalboni/89954974f90e7e05c4b52cc8b0c790de to your computer and use it in GitHub Desktop.
Save alexcasalboni/89954974f90e7e05c4b52cc8b0c790de to your computer and use it in GitHub Desktop.
Amazon Aurora MySQL - Trigger to invoke AWS Lambda
DROP TRIGGER IF EXISTS TR_contacts_on_insert;
DELIMITER ;;
CREATE TRIGGER TR_contacts_on_insert
AFTER INSERT ON Contacts
FOR EACH ROW
BEGIN
SELECT NEW.email , NEW.fullname
INTO @Email , @Fullname;
lambda_async(
'arn:aws:lambda:REGION:ACCOUNT_ID:function:SendEmailWithContact',
CONCAT('{ "email" : "', Email, '", "fullname" : "', FullName, '"}')
);
END
;;
DELIMITER ;
@wakeupmh
Copy link

wakeupmh commented May 6, 2022

hey dude, did you face an error like that?
Lambda API returned an error: Missing IAM Credentials for specified aws_default_lambda_role
I'm stuck on this error :(

@a2tt
Copy link

a2tt commented May 8, 2022

hey dude, did you face an error like that? Lambda API returned an error: Missing IAM Credentials for specified aws_default_lambda_role I'm stuck on this error :(

@wakeupmh Did you find the solution? I think Giving Aurora access to Lambda will help. aws_default_lambda_role is mentioned in step 3.
Also make sure you granted AWS_LAMBDA_ACCESS role to the DB user. See details from here

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment