Skip to main content

AWS Redshift

With this integration you can query and modify data from your Redshift databases.

Credential configuration

To fill the form params you need the Access key id and the Secret access key of the Programatic access user you want to use. This user needs the permissions to have access to Redshift to work properly. If you need to create the user, you can see how to do it here.

In the extra options field you can pass any of the params you can find here.

Here you have an example of a filled credential configuration form in YepCode:

AWS Redshift snippets available in YepCode editor

note

The title is the triggering text for YepCode to autocomplete the script

Integration

New integration from credential
const awsRedshiftClient = yepcode.integration.awsRedshift("credential-slug");
New integration from plain authentication data
const { RedshiftDataClient } = require("@aws-sdk/client-redshift-data");

const awsRedshiftClient = new RedshiftDataClient({
credentials: {
accessKeyId: "accessKeyId",
secretAccessKey: "secretAccessKey",
},
});

Execute statement

Execute statement
const { ExecuteStatementCommand } = require("@aws-sdk/client-redshift-data");

const executeStatementCommand = new ExecuteStatementCommand({
ClusterIdentifier: "{2:clusterIdentifier}",
Database: "{3:database}",
DbUser: "{4:dbUser}",
Sql: "{5:sql}",
});

const executeStatementResult = await awsRedshiftClient.send(executeStatementCommand);
console.log(`Statement id: ${executeStatementResult.Id}`);

Execute statement with parameters

Execute statement with parameters
const { ExecuteStatementCommand } = require("@aws-sdk/client-redshift-data");

const executeStatementCommand = new ExecuteStatementCommand({
ClusterIdentifier: "{2:clusterIdentifier}",
Database: "{3:database}",
DbUser: "{4:dbUser}",
Sql: "{5:your sql with params as :paramName}",
Parameters: [
{
name: "paramName",
value: "{6:value}",
},
],
});

const executeStatementResult = await awsRedshiftClient.send(executeStatementCommand);
console.log(`Statement id: ${executeStatementResult.Id}`);

Get statement result

Get statement result
const { GetStatementResultCommand } = require("@aws-sdk/client-redshift-data");

const getStatementResultCommand = new GetStatementResultCommand({
Id: "{2:statementId}",
});

awsRedshiftClient.send(getStatementResultCommand).then(result => {
console.log(getStatementResult.Records)
})

List statements

List statements
const { ListStatementsCommand } = require("@aws-sdk/client-redshift-data");

const listStatementsCommand = new ListStatementsCommand({});

awsRedshiftClient.send(listStatementsCommand).then(result => {
console.log(result.Statements);
});