Hana Chris
Hana Chris

Reputation: 1

When to use lambda with api gateway and dynamodb

I am new to aws. I read few articles to directly connect api gateway to DynamoDB and few used lambda to route the requests. I want to understand in what cases we need lambda and when we can avoid it.

Upvotes: 0

Views: 269

Answers (1)

user212514
user212514

Reputation: 3130

It is super-convenient that API Gateway can insert directly into DynamoDB. Many times that is sufficient. There may be times when you need to do "a little more" than just insert into DynamoDB. For example, you may need to:

  1. Append some additional data to items going into a DynamoDB table (like a postal code)
  2. Reformat some of the data (like split a name field into first name and last name)
  3. Execute some other action (like also insert into an RDS database)

Processing a DynamoDB stream is another way in which you might handle those actions. However, DynamoDB stream processing happens asynchronously so you cannot immediately report a failure back through the original API Gateway endpoint. For example, if there's a problem in the Lambda you may want to have the API Gateway endpoint reply with an appropriate HTTP status code so that the caller knows about the problem.

Upvotes: 2

Related Questions