Skip Lambda, Save Data to DynamoDB Directly Using API Gateway; Process Later With Streams

Chris Bailey
The Startup
Published in
9 min readNov 23, 2020

--

AWS’ API Gateway allows you to directly connect it to/proxy many other AWS services. This article discusses doing this with DynamoDB, as a way to create an API that adds data to DynamoDB, without needing to use a Lambda function. There are existing AWS docs on using API Gateway as a proxy for DynamoDB, however, as usual, those only cover how to do this in the AWS console. In particular, I’ll show how I set this up using the Serverless Framework (or CloudFormation, as the bulk is really just CloudFormation code), and how you transform the web request’s JSON so it can be directly PUT into DynamoDB. Finally, I’ll talk about how to then do post-processing of the data via DynamoDB Streams.

But Why?

The use case I have is an authenticated web API that takes in a potentially significant volume of events from mobile devices. This data will be stored in DynamoDB. As an additional constraint, the mobile app is sending via regular HTTP web calls, and doesn’t have the ability to use GraphQL (i.e. AppSync isn’t a possibility for this case). Finally, I want this particular API to be simple and very fast, and all the (time consuming) processing of the data will be done async. Thus, we can simply have the data come in via API Gateway and get injected directly into DynamoDB (with…

--

--

Chris Bailey
The Startup

NatureQuant CTO/Co-founder. HotelTonight Co-founder. Cyclist, trail runner, skier, espresso & coffee lover, geek, traveler, foodie.