Reputation: 1151
I am trying to connect to DynamoDB from my local NodeJS app. My configuration is as follows:
connect-database.js
const mongoose = require('mongoose')
const fs = require('fs')
const path = require("path")
const connectDatabase = (mongoDbUrl) => {
mongoose.connect(mongoDbUrl, {
useNewUrlParser: true,
useUnifiedTopology: true,
ssl: true,
sslValidate: false,
sslCA: fs.readFileSync(path.resolve(__dirname, '../../config/rds-combined-ca-bundle.pem'))
})
}
index.js
connectDatabase('mongodb://<username>:<password>@<connection-string>/?ssl=true&ssl_ca_certs=rds-combined-ca-bundle.pem&replicaSet=rs0&readPreference=secondaryPreferred&retryWrites=false')
I felt it had something to do with security group inbound rules so I have added it to allow inbound from all protocols and all ports on my security group but it still won't work. It's even more confusing since I am able to connect to it from my AWS Cloud9 instance.
The error I get is MongooseServerSelectionError: getaddrinfo ENOTFOUND. It means it is unable to connect to the database at all.
Upvotes: 1
Views: 939