Do I really need a Lambda to fetch an item from DynamoDB?

aws

#1

Hi guys!

I made an endpoint GET /resource/{id} which get or scan an item without the need to call a Lambda, only using API GW which calls DynamoDB directly.

These approach follows the “good practices”?
What you guys think that could be wrong?
Will I get into troubles in the future?
Theoretically, I will have a cost reduction and better latency, right?

I’ve done this, because having a Lambda only fetching things from Dynamo without performing any business logical didn’t make sense for me. Furthermore, Dynamo, as many other services, is HTTP accessible, so why not call it directly?

Thanks


#2

Amazon API Gateway has a feature that enables customers to create their own API definitions directly in front of an AWS service API.

In fact your idea is good, you don’t have to always send the requests to lambda, aws provides other way, such as DynamoDB, Kinesis, cloudwatch. The choice depends on your own business.

I think you are following this aws document (https://aws.amazon.com/blogs/compute/using-amazon-api-gateway-as-a-proxy-for-dynamodb/) for the implementation to let api gateway talk to dynamodb via AWS Service Proxy


#3

Yeah … I did this for a while for one of our calls.
https://drive.google.com/open?id=1bZ969fStZkw-QR8-TB5Yv11gePchwk9x

Initially I did it for the performance. I found that since we didn’t need the performance improvement on the call, the overhead of maintaining the Apache Velocity code just became a drag at some point so I converted it over to Lambda. Perhaps, if this was the primary call of the system and it would save significant money on Lambda calls, that might be another reason to do it.

Carmine


#4

Thank you for your contribution!

I performed this by using API GW UI. And yes, there is an overhead maintaining the Apache Velocity code…

Do you know if AWS SAM do a better job? I think we need to create a Swagger file with all API GW configuration and Apache Velocity code.