Skip to main content

AWS Redshift

Credential configuration

To configure this credential, you need the Access Key ID and the Secret Access Key of the Programatic access user you want to use. Make sure this user has the required permissions to access Redshift to work properly. If you need to create the user, follow the instructions provided here.

In the extra options field, you can include any of the parameters found here.

Here is 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: "clusterIdentifier",
Database: "database",
DbUser: "dbUser",
Sql: "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: "clusterIdentifier",
Database: "database",
DbUser: "dbUser",
Sql: "your sql with params as :paramName",
Parameters: [
{
name: "paramName",
value: "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: "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);
});