[Tutorial] Serverless Webhooks with AWS

Recently I’ve been exploring various AWS services, mainly for use as a severless solution as an extension EBS, but I’ve found that they can also work quite nicely as a way to handle Webhook subscription and notification handling.

I’ve put together a tutorial of what I’ve learned in the hopes that others may get some use out of it, especially those who want to take advantage of some of the benefits of webhooks over polling but maybe don’t have the resources for an always on server, or a service that is internet accessible.

Topics Covered
DynamoDB - Basic setup of a database table to handle storage of incoming notifications.
IAM - Configuring the rights for Lambda functions to access the database.
Lambda - Functions to handle the subscription/resubscription of webhooks, and process incoming notifications.
API Gateway - Internet accessible gateway for the required GET and POST requests from Twitch.
CloudWatch - Automatic renewal of subscriptions through use of scheduled events.

Things to keep in mind
All of my Lambda function examples are written in Javascript for Node.js 8.10, but for those more familiar with other languages Lambda also supports Python, Java, Go, and C#.

I’m not an AWS expert, I just put this tutorial together from things I’ve learned while exploring various services, it is not intended to be used in a production environment and is just a starting point for people that will be sufficient for people to quickly and easily start putting together various services themselves to meet the needs of their own use cases.

One of the main reasons for me investigating AWS and if it’s fit for purpose for my use cases is that some services have a free tier that is indefinite, which dramatically limits the cost for services that don’t require an always-on server. I’m not going to go into cost projections, as it’s entirely dependant on individual use cases, so for some it could be great, for others it simply may not be fit for their use case without including the more expensive offerings from AWS (such as EC2 or RDS).

If anyone is interested in more tutorials for various things, be it working with parts of the Twitch API, or more about different online services I try, I’d appreciate a follow on Twitch as I plan to start streaming step-by-step guides, as well as just poking around services and new features to try stuff out, in the future.

4 Likes

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.