1.0.0-alpha.29 • Published 6 years ago
mongodb-aws-documentdb-tunneling v1.0.0-alpha.29
MongoDB with AWS DocumentDB
MongoDB wich allow SSH tunneling into a AWS DocumentDB VPC by going through a EC2 instance hosted in the same VPC while also allowing local MongoDB in local
environment.
Installation
npm install mongodb-aws-documentdb-tunneling --save
Usage Example
Connection
To use this SDK, call the init
function as early as possible in the entry modules:
app.js
const MONGODB = require('mongodb-aws-documentdb-tunneling')
MONGODB.init({
env: process.env.ENV === 'dev'
? 'local'
: 'remote',
makeTunnel: process.env.IN_VPC === 'false'
? false
: true,
sslCA: FS.readFileSync(
PATH.join(__dirname, 'keys', process.env.VPC_TUNNEL_EC2_RDS_SSL_CA_KEY), 'utf8'
),
vpcTunnelEC2Username: process.env.VPC_TUNNEL_EC2_USERNAME,
vpcTunnelEC2Host: process.env.VPC_TUNNEL_EC2_HOST,
vpcTunnelEC2Port: process.env.VPC_TUNNEL_EC2_PORT,
documentdbClusterEndpoint: process.env.DOCUMENTDB_CLUSTER_ENDPOINT,
documentdbClusterPort: process.env.VPC_TUNNEL_EC2_PORT_DESTINATION,
vpcTunnelEC2PortLocal: process.env.VPC_TUNNEL_EC2_PORT_LOCAL,
vpcTunnelEC2PrivateKey: FS.readFileSync(
PATH.join(__dirname, `keys/${process.env.VPC_TUNNEL_EC2_PRIVATE_KEY}`), 'utf8'
),
documentdbClusterDbName: process.env.DOCUMENTDB_CLUSTER_DB_NAME,
documentdbClusterUsername: process.env.DOCUMENTDB_CLUSTER_USERNAME,
documentdbClusterPassword: process.env.DOCUMENTDB_CLUSTER_PASSWORD,
documentdbEndpoint: process.env.DOCUMENTDB_ENDPOINT,
})
.then(success => DEBUG(success))
.catch(error => { throw error })
Query
users.module.js
const const { MongoClient: MONGODB } = require('mongodb-aws-documentdb-tunneling')
/**
* Get all users from 'onsite' database.
* @returns {Promise<[<user>]>} users
*/
function getOnSiteUsers() {
return MONGODB()
.db('onsite')
.collection('users')
.find()
.toArray()
}
Troubleshooting
- ...
1.0.0-alpha.29
6 years ago
1.0.0-alpha.28
6 years ago
1.0.0-alpha.24
6 years ago
1.0.0-alpha.23
6 years ago
1.0.0-alpha.22
6 years ago
1.0.0-alpha.21
6 years ago
1.0.0-alpha.20
6 years ago
1.0.0-alpha.19
6 years ago
1.0.0-alpha.18
6 years ago
1.0.0-alpha.16
6 years ago
1.0.0-alpha.15
6 years ago
1.0.0-alpha.14
6 years ago
1.0.0-alpha.13
6 years ago
1.0.0-alpha.12
6 years ago
1.0.0-alpha.11
6 years ago
1.0.0-alpha.10
6 years ago
1.0.0-alpha.9
6 years ago
1.0.0-alpha.8
6 years ago
1.0.0-alpha.7
6 years ago
1.0.0-alpha.5
6 years ago
1.0.0-alpha.4
6 years ago
1.0.0-alpha.3
6 years ago
1.0.0-alpha.2
6 years ago
1.0.0-alpha.1
6 years ago
1.0.0-alpha.0
6 years ago