question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

AWS.RDS.signer + Connection pooling ?

See original GitHub issue

I am wondering if you have any suggestions for the following situation:

I would like to use AWS.RDS.signer to generate password tokens for use in a connection pool. I have put together something like the following…

const createPool = () => new Promise((resolve, reject) => {
    signer.getAuthToken({
        region: '...',
        hostname: '...',
        port: '...',
        username: '...'
    }, (err, token) => {
        if (err) reject(err)
        const pool = mysql.createPool({
            host: '...',
            port: '...',
            user: '...',
            database: '...',
            password: token,
            ssl: 'Amazon RDS'
            authSwitchHandler: (data, cb) => {
                if (data.pluginName === 'mysql_clear_password') cb(null, Buffer.from(token + '\0'))
            }
        })
        resolve(pool)
    })
})

…and it works great – but only for 15 minutes, and then the AWS token expires. At that point new connections cannot be established in the pool.

Is there any way to update the pool config options after the pool has been created, so I can keep the token fresh? Would you perhaps consider letting a function be passed as the password property, so that it can return a dynamic value at the time a connection is created? Otherwise, it really isn’t practical to use the aws signer with connection pooling, as I understand it.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:15 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
awcchungstercommented, May 22, 2020

That worked! Thanks. I really appreciate it.

It would be great to have this in documentation.

For my own learning, how does return () => { change the response object? Is this a specific structure in ES6?

1reaction
rabbitfufucommented, Sep 23, 2019

Thanks for the super fast response, and thanks for the extremely helpful advice! That is exactly what I am looking for. Much appreciated.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Using Amazon RDS Proxy with AWS Lambda
RDS Proxy helps you manage a large number of connections from Lambda to an RDS database by establishing a warm connection pool to...
Read more >
node-mysql2, AWS.RDS.signer, & connection pooling
RDS.signer. I have the following function, which creates a connection pool for reusing connections: const createPool = () ...
Read more >
Using AWS RDS Proxy to Pool Database Connections from ...
Connection pooling is when a certain number of database connections are kept alive so that when a request comes in that needs to...
Read more >
AWS RDS Proxy w/ IAM Authentication enabled to Aurora SLS ...
Amazon RDS Proxy allows applications to pool and share connections established with the database. In this article, we will see how we can ......
Read more >
Introduction to RDS Proxy - YouTube
RDS Proxy is a fully managed database proxy for Amazon Relational Database Service ( RDS ) that makes applications more scalable, ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found