Reputation: 9522
I'm using an Amazon RDS hosted MySQL with Multi-AZ Support. Just could not find any information on how to connect Sequelize to Amazon RDS properly so that Sequelize is handling fail-overs etc. accordingly?
I'm just using the following config, but do not know if this is enough or recommended?
sequelizeConfig = {
logging: false,
pool: { maxConnections: 5, maxIdleTime: 30},
sequelizeConfig[dialectOptions] = {
ssl: 'Amazon RDS'
}
}
Using Amazon RDS with Multi-AZ I consider the following is important:
Amazon Docs are not writing anything about connection handling and pooling.
Upvotes: 15
Views: 22672
Reputation: 1
ssl: 'Amazon RDS'
didn't work for me.
After some digging, this worked:
var options = {
host: settings.database.host,
port: settings.database.port,
logging: console.log,
dialect: 'mysql',
"dialectOptions": {
"ssl": {
"ca": fs.readFileSync('./eu-central-1-bundle.pem')
}
}
}
Where eu-central-1-bundle.pem is aws CA certificate necessary to connect to the mysql rds DB.
Upvotes: 0
Reputation: 47
The previous answer didn't work for me, after some research, this options object did:
var options = {
host: settings.database.host,
port: settings.database.port,
logging: console.log,
maxConcurrentQueries: 100,
dialect: 'mysql',
ssl: 'Amazon RDS',
pool: { maxConnections: 5, maxIdleTime: 30 },
language: 'en',
}
I'm running a RDS MySQL and a EC2 instance in the same default VPC, this options object worked when connecting a node app from that EC2 with the RDS using sequelize.
Upvotes: 1
Reputation: 2609
Here is how i got connected with my RDS:
var config = require(__dirname + '/../config/config.json')[env];
// your config file will be in your directory
var sequelize = new Sequelize(config.database, config.username, config.password, {
host: '****.****.us-west-1.rds.amazonaws.com',
port: 5432,
logging: console.log,
maxConcurrentQueries: 100,
dialect: 'postgres',
dialectOptions: {
ssl:'Amazon RDS'
},
pool: { maxConnections: 5, maxIdleTime: 30},
language: 'en'
})
Upvotes: 18