cube-js/cube

Automatically retrieve Redshift cluster credentials

Open

#306 建立於 2019年12月21日

在 GitHub 查看
 (3 留言) (0 反應) (0 負責人)Rust (19,563 star) (1,965 fork)batch import
driver:redshifthelp wanted

描述

Is your feature request related to a problem? Please describe. The AWS Redshift SDK allows retrieving credentials via an API:

import Redshift, { ClusterCredentials } from 'aws-sdk/clients/redshift';

const getCredentials = async () => {
  const creds = await redshift.getClusterCredentials({
    ClusterIdentifier: process.env.CUBEJS_DB_HOST,
    DbUser: process.env.CUBEJS_DB_USER,
  }).promise();

  if (!creds.DbUser && !creds.DbPassword) {
    throw new Error('Unable to retrieve Redshift credentials');
  }

  return creds as Required<ClusterCredentials>;
};

getCredentials()
  .then((credentials) => {
    const config = {
      database : process.env.CUBEJS_DB_NAME,
      host: process.env.CUBEJS_DB_HOST,
      password : creds.DbPassword,
      port: process.env.CUBEJS_DB_PORT,
      user: creds.DbUser,
    };
  })

Describe the solution you'd like

It would be great if CubeJS would automatically attempt to do the above if the CUBEJS_DB_PASS environment variable is omitted for Redshift projects.

Additional context A Serverless project using Redshift would require additional permissions to the IAM role:

iamRoleStatements:
    - Effect: 'Allow'
      Action:
        - 'redshift:GetClusterCredentials'
      Resource:
        - '<REDSHIFT_CLUSTER_ARN>/<REDSHIFT_USER>'

貢獻者指南