-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Closed
Labels
Description
RDS postgres supports connecting via an "IAM Authentication Token", which lasts 15 minutes, and is used as the password when connecting to the database. I can't see any way to connect like this with pg, since the password is a static value passed at pool creation time. Ideally, the pool would be able to retrieve a new password whenever it needs to create a new connection.
I think the ideal API for this would be something like this - note the getPassword function needs to be asynchronous:
const { Pool } = require('pg')
const pool = new Pool({
user: 'dbuser',
host: 'database.server.com',
database: 'mydb',
getPassword: function () {
// return a promise which resolves with the generated password
},
port: 3211,
})
I am most likely available to work on this issue, but keen to get maintainer approval first before I write any code.
More details here:
https://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/UsingWithRDS.IAMDBAuth.Connecting.AWSCLI.PostgreSQL.html
samueljseay, sbe-arg, pmacdougall and kellertobias