REST API for Redshift

懵懂的女人 提交于 2019-12-22 06:46:22

问题


I'm currently brainstorming an idea and trying to figure out whether it's feasible or a better way to handle this approach.

Assume I have a Redshift table and I want to expose this table through a REST API. For example, there are several customer who needs some kind of meta data from this table. They will call a REST service and it will execute on the Redshift to get the data and will response to the client in JSON format.

I'm fairly new in Redshift/AWS area so not sure whether AWS already have something for that? I know S3 supports REST API.

Does it sound feasible? I can definitely write typical RESTful service using Java while reading data from Redshift using JDBC. But wanted to know if there is a better way to handle this in AWS world.


回答1:


The Amazon API Gateway can expose a public API and will then call a Lambda function upon invocation. The Lambda function can do whatever you wish!

For some AWS services, API Gateway can also act as a proxy to the normal API calls (eg Create an AWS Service Proxy for Amazon SNS. However, making SQL calls to Amazon Redshift involves connecting to the database as a client, rather than making API calls to AWS.

Therefore, you would need to:

  • Write an AWS Lambda function (in either Node.js, Java or Python)
  • Have the function connect to the Amazon Redshift database and perform an SQL call
  • Define an API Gateway API that receives the REST request and forwards it to the Lambda function

It may seem complex, but if should be straight-forward if you break it down into components and get each one working in turn.

API Gateway also has the ability to cache responses, which can provide faster performance by not always connecting to Amazon Redshift (eg for recently accessed or slow-changing data).



来源:https://stackoverflow.com/questions/38023578/rest-api-for-redshift

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!