Sreekuttan Jayakumar
Sreekuttan Jayakumar

Reputation: 31

Querying and updating Redshift through AWS lambda

I am using a step function and it gives a JSON to the Lambda as event(object data from s3 upload). I have to check the JSON and compare 2 values in it(file name and eTag) to the data in my redshift DB. If the entry does not exist, I have to classify the file to a different bucket and add an entry to the redshift DB(versioning). Trouble is, I do not have a good idea of how I can query and update Redshift through Lambda. Can someone please give suggestions on what methods I should adopt? Thanks!

Edit: Should've mentioned the lambda is in Python

Upvotes: 1

Views: 1739

Answers (1)

smac2020
smac2020

Reputation: 10724

One way to achieve this use case is you can write the Lambda function by using the Java run-time API and then within the Lambda function, use a RedshiftDataClient object. Using this API, you can perform CRUD operations on a Redshift cluster.

To see examples:

https://github.com/awsdocs/aws-doc-sdk-examples/tree/master/javav2/example_code/redshift/src/main/java/com/example/redshiftdata

If you are unsure how to build a Lambda function by using the Lambda Java run-time API that can invoke AWS Services, please refer to :

Creating an AWS Lambda function that detects images with Personal Protective Equipment

This example shows you how to develop a Lambda function using the Java runtime API that invokes AWS Services. So instead of invoking Amazon S3 or Rekognition, use the RedshiftDataClient within the Lambda function to perform Redshift CRUD opertions.

Upvotes: 2

Related Questions