用于Redshift的REST API [英] REST API for Redshift

查看:174
本文介绍了用于Redshift的REST API的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前正在集思广益,试图弄清楚这是可行还是更好的方法。

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

假设我有一个Redshift表,我希望通过REST API公开此表。例如,有几个客户需要此表中的某种元数据。他们将调用REST服务,它将在Redshift上执行以获取数据并以JSON格式响应客户端。

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.

我在Redshift / AWS区域,因此不确定AWS是否已经为此提供服务?我知道S3支持REST API。

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

听起来可行吗?我绝对可以使用Java编写典型的RESTful服务,同时使用JDBC从Redshift读取数据。但是想知道在AWS世界中是否有更好的方法来解决这个问题。

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.

推荐答案

Amazon API网关可以公开公共API,然后在调用时调用Lambda函数。 Lambda函数可以做任何您想做的事!

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!

对于某些AWS服务,API网关还可以充当常规API调用的代理(例如为Amazon SNS创建AWS服务代理。但是,要编写SQL对Amazon Redshift的调用涉及作为客户端连接到数据库,而不是对AWS进行API调用。

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.

因此,您需要:


  • 编写一个 AWS Lambda函数(在Node.js,Java或Python中)

  • 具有函数连接到Amazon Redshift数据库并执行SQL调用

  • 定义用于接收REST请求并转发的 API Gateway API 到Lambda函数

  • 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

它似乎很复杂,但是如果将它分解成几个部分并分别获取,则应该很简单一个在土里工作rn。

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网关还具有缓存响应,它可以通过不总是连接到Amazon Redshift(例如,用于最近访问或变化缓慢的数据)来提供更快的性能。

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).

这篇关于用于Redshift的REST API的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆