ashoksl
ashoksl

Reputation: 383

How to call two endpoints for a single request

We have an existing endpoint published in AWS Api Gateway POST https://publicendpoint/app/users which points to the internal endpoint https://microservice1/app/users.

As we're in the process of backend database migration, whenever https://publicendpoint/app/users is called, we need to call two endpoints

https://microservice1-olddb/app/users and

https://microservice1-newdb/app/users .

How to do this?

Have tried with creating a API Gateway trigger with lambda. But not able to achieve this scenario with lambda trigger.

Upvotes: 0

Views: 550

Answers (1)

K Mo
K Mo

Reputation: 2155

API Gateway doesn't do any orchestration, so you can't point it at both endpoints. And even if it did, how would you handle one service failing, which service takes precedence with the response given etc.

The simplest answer is probably to use a Lambda as an orchestration layer. That is point API Gateway at a Lambda which in turn calls both endpoints.

Upvotes: 3

Related Questions