Chapter 17. Receiving events from other services

This chapter covers

  • Having external sources as triggers for Lambda functions
  • Using webhooks to receive callbacks from other services
  • Monitoring application logs to trigger Lambda functions
  • Introducing practical examples with tools such as Slack, GitHub, Twilio, and MongoDB

In the previous chapter, you learned how to call external services in Lambda functions, encrypting credentials before including them in your code or in your configuration repositories.

Now you’ll see the other side of that: how to have Lambda functions triggered by external services. I’ll share specific examples and best practices, and the architectural patterns that are introduced here can be used with many more services than those included in this chapter.

17.1. Who’s calling?

You can use other AWS services, such as the Amazon API Gateway and Amazon SNS, to receive events from sources outside of AWS. In that case, you can’t trust anyone and you should have a process in place to verify that the source of the event is who you expect. Usually, you can verify that by adding a shared secret (between you and the source) to all events, or even better, by adding a digital signature to the request, similar to how the AWS API works.

17.2. The webhook pattern

17.3. Handling events from Slack

17.4. Handling events from GitHub

17.5. Handling events from Twilio

17.6. Using MongoDB as a trigger

17.7. The log monitoring pattern