Asier Gomez
Asier Gomez

Reputation: 6588

Nodejs connect to Redshift using temporal credentials error

I'd like to connect to Redshift using temporal credentials.

I'd tried connecting with master username and password and it works fine. The problem of the temporal credentials is the username that is following format:

username: 'IAM:awsuser'.

So I think the connection is not understanding correctly the ":". So it always through invalid password. I have try this username and password from the Redshift query-editor and it connects without any problem.

This is the configuration I'm using:

const configRed = {
  host: 'redshift-cluster-name.aaaaaaa.eu-west-1.redshift.amazonaws.com',
  user: 'IAM:awsuser',
  password: data.DbPassword,
  database: 'dev',
  port: 5439,
  idleTimeoutMillis: 0,
  max: 10000
};

redshiftPool = new psql.Pool(configRed);

redshiftCon = await redshiftPool.connect();

I have also tried using the username with encodeURIComponent:

    user: encodeURIComponent('IAM:awsuser'),

It through next error:

  "errorMessage": "password authentication failed for user \"IAM:awsuser\"",

Could be possible to change the connection URL in the PG library, for some custom URL like:

jdbc:redshift:iam://examplecluster.abc123xyz789.us-west-2.redshift.amazonaws.com:5439/dev

Upvotes: 1

Views: 808

Answers (1)

Asier Gomez
Asier Gomez

Reputation: 6588

Specifying "ssl: true" in the params argument when creating the Pool object indeed works:

const configRed = {
  host: 'redshift-cluster-name.aaaaaaa.eu-west-1.redshift.amazonaws.com',
  user: 'IAM:awsuser',
  password: data.DbPassword,
  database: 'dev',
  port: 5439,
  idleTimeoutMillis: 0,
  max: 10000,
  ssl: true
};

Upvotes: 2

Related Questions