{"id":3269,"date":"2015-08-13T20:15:00","date_gmt":"2015-08-13T19:15:00","guid":{"rendered":"https:\/\/www.devco.net\/?p=3269"},"modified":"2015-08-14T12:34:33","modified_gmt":"2015-08-14T11:34:33","slug":"translating-webhooks-with-aws-api-gateway-and-lambda","status":"publish","type":"post","link":"https:\/\/www.devco.net\/archives\/2015\/08\/13\/translating-webhooks-with-aws-api-gateway-and-lambda.php","title":{"rendered":"Translating Webhooks with AWS API Gateway and Lambda"},"content":{"rendered":"

Webhooks are great, so many services now support them but I found actually doing anything with them a pain as there are no standards for what goes in them and any 3rd party service you wish to integrate with has to support the particular hooks you are producing.<\/p>\n

For instance I want to use SignalFX for my metrics and events but they have very few integrations. A translator could take an incoming hook and turn it into a SignalFX event and pass it onward.<\/p>\n

For a long time I’ve wanted to build a translator but never got around to doing it because I did not feel like self hosting it and write a whole bunch of supporting infrastructure. With the release of AWS API Gateway this has become quite easy and really convenient as there are no infrastructure or instances to manage.<\/p>\n

I’ll show a bit of a walk through on how I built a translator that sends events to Signal FX. Note I do not do any kind of queueing or retrying on the gateway at present so it’s lossy and best efforts.<\/p>\n

AWS Lambda runs stateless functions on demand. At launch it only supported ingesting their own Events but the recently launched API Gateway lets you front it using a REST API of your own design and this made it a lot easier.<\/p>\n

For the rest of this post I assume you’re over the basic hurdles of signing up for AWS and are already familiar with the basics, so some stuff will be skipped but it’s not really that complex to get going.<\/p>\n

The Code<\/H2>
\nTo get going you need some JS code to handle the translation, here’s a naive method to convert a GitHub push notification into a SignalFX event:<\/p>\n