sidorares / sidorares/node-mysql2
Add a function to update pool default configurations
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 4.4k
- Forks
- 680
- Avg merge
- 9h 7m
- Merged PRs (30d)
- 59
Description
Hello,
I'm working in a project that uses a MySQL instance running on AWS RDS and to improve security we're using IAM based authentication, which means that the password to create new connections with the database expires 15 minutes after its creation time and we need to generate a new one in order to create new connections.
When we use a simple connections, it works fine...
import { Signer } from "@aws-sdk/rds-signer";
// generate a new RDS token
const signer = new Signer();
const token = await signer.getAuthToken();
const connection = mysql.createConnection({
host: 'aws.address...,
user: 'iam_based_authentication_user',
database: 'my_db',
});
The problem happens when we create a new pool using the RDS token. After 15 minutes (when the token is not valid anymore) we're not able to update pool configurations with a new valid token and that's preventing us to create new connections.
import { Signer } from "@aws-sdk/rds-signer";
// generate a new RDS token
const signer = new Signer();
const token = await signer.getAuthToken();
const pool = mysql.createPool({
host: 'aws.address...,
user: 'iam_based_authentication_user',
database: 'my_db',
password: token,
});
// Works fine
const connection = await pool.getConnection();
// Wait for 15 minutes and run it again...
// This code is going to fail, once the RDS token that is stored at the pool is not valid anymore.
// At this point I could generate a new RDS token, but I'm not able to update the password for pool's instance
const connection2 = await pool.getConnection();
Do you folks think that is possible to add a function to update the pool default configurations in order to change new connection attributes?
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start at the pool created by mysql.createPool and trace how pool.getConnection uses its default configuration. Review the @aws-sdk/rds-signer token flow and determine how updated connection attributes should affect new connections; done means a pool can accept a refreshed password after the token expires without disrupting existing connections.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- aws, mysql, nodejs, typescript
- Domain
- database
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 38/100