0

Use Case: I need to perform an API request mapping that requires data from DynamoDB.

Desired Solution: I'd like to do this using API Gateway features if possible, which would look something like this:

  1. An external REST API request is received by API Gateway
  2. A Proxy Resource extracts a parameter, say accountId, from the HTTP path
  3. A Service Integration (GetItem) reads a set of values from DynamoDB using the accountId key
  4. The values read from the DB are input to a Request Mapper VTL template
  5. The transformed API request is then sent to an HTTP Integration endpoint

Questions:

  • Is that possible to do using API Gateway out-of-the-box or is that sequence too advanced?
  • If it's not possible, then is a lambda the best option to do most of this work (read DB, transform request, route HTTP)?

Thanks for your help!

1 Answer 1

1

API Gateway will not make DB queries for you. Routing this through a Lambda function is the best option here.

Sign up to request clarification or add additional context in comments.

5 Comments

API > Child Resource > Integration Type = AWS Service, AWS Service = DynamoDB, Action: GetItem. See here
That just runs a direct query and returns the result. It's not something that you could use in routing rules in order to forward the request somewhere else.
The result of the query can be mapped into the body of an API response, so I figured it might be possible to map the result to the body of a new API request and forward that to a fixed endpoint via HTTP Integration. No dynamic routing necessary.
I get what you are saying, but that's exactly what I'm saying API Gateway won't do. You can't make API calls to DynamoDB (or anything else) as part of request mapping.
Got it, just wanted to be sure we're on the same page. Thanks for your reply!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.