/lambda2sns

Lambda function invoked by AuroraDB to the atest SNS Topic

Primary LanguageGoGNU Affero General Public License v3.0AGPL-3.0

Build Status

Lambda2sns

lambda2sns originally started life as a bridge for Aurora CALL mysql.lambda_async payloads to SNS to be subscribed to. It has evolved to do a lot more, with most of the complexity coming from the requirement to write results back to the originating database.

lambda: arn:aws:lambda:ap-southeast-1:812644853088:function:alambda_simple
sns: arn:aws:sns:ap-southeast-1:812644853088:atest

Setup Aurora to trigger a lambda event

SELECT lambda_sync(
	'arn:aws:lambda:ap-southeast-1:812644853088:function:alambda_simple',
	'{"operation": "ping"}');

Create an email subscription on the SNS topic:

https://ap-southeast-1.console.aws.amazon.com/sns/v2/home?region=ap-southeast-1#/topics/arn:aws:sns:ap-southeast-1:812644853088:atest

Then you should get an email of the JSON payload.

Deploy and test

make

View logs

Last five minutes

Setup

sns topic

[hendry@t480s alambda]$ aws --profile uneet-demo sns create-topic --name atest
{
	"TopicArn": "arn:aws:sns:ap-southeast-1:915001051872:atest"
}
[hendry@t480s alambda]$ aws --profile uneet-prod sns create-topic --name atest
{
	"TopicArn": "arn:aws:sns:ap-southeast-1:192458993663:atest"
}

How to subscribe:

aws --profile uneet-prod sns subscribe --protocol email --topic-arn arn:aws:sns:ap-southeast-1:192458993663:atest --notification-endpoint youremail@example.com

Don't forget to confirm the subscription.

Wonderful world of time wasting permission errors

Lambda API returned error: Missing Credentials: Cannot instantiate Lambda Client

Read: https://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/AuroraMySQL.Integrating.Lambda.html#AuroraMySQL.Integrating.LambdaAccess

Lambda API returned error: Missing Credentials: Cannot instantiate Lambda Client

You need to IAM roles to this cluster https://ap-southeast-1.console.aws.amazon.com/rds/home?region=ap-southeast-1#dbclusters: