What I absolutely love about AWS Lambda is that it can be triggered by other AWS resources like SNS notifications, S3 files and more. If you think of the workflows you can achieve with this you can easily see some powerful applications can be built on top of it.

Lets move on though and focus on the code since that’s what we’re here for

For our example, lets create a Lambda function that will be a subscriber to SNS notification.

To be exact, lets say we want to get a Slack notification every time a deployment fails on ElasticBeanstalk so that the engineers can check it out.

Receiving the message via STDIN m := os.Args[1] , calling the parser parser := snsparser.NewSNSParser([]byte(m) and checking if the message includes what we want failed, message := parser.IncludesMessage("Failed to deploy application") . From there we continue with what we want to do.

Extend for your use case

I chose the simplest use case possible of receiving a JSON object and processing it. Even though this workflow is pretty simple I think you can extend it to pretty much anything you want.

One of the things I am going to migrate away from the application and into these function is callbacks from third party services. All callbacks to Gogobot will go through Lambda functions eventually. Queue processing is another perfect example on how you can use these.