Socket
Socket
Sign inDemoInstall

elasticsearch-aws-tunneling

Package Overview
Dependencies
35
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    elasticsearch-aws-tunneling

Elasticsearch wich allow SSH tunneling into a AWS Elasticsearch VPC by going through a EC2 instance hosted in the same VPC.


Version published
Weekly downloads
8
Maintainers
1
Install size
4.19 MB
Created
Weekly downloads
 

Readme

Source

Mongoose with AWS DocumentDB

lerna

Mongoose 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 mongoose-aws-documentdb-tunneling --save

Usage Example

To use this SDK, call the init function as early as possible in the entry modules after registering your models.

Models

In your models, use mongoose from the mongoose-aws-documentdb-tunneling SDK:

User.model.js
const MONGOOSE = require('mongoose-aws-documentdb-tunneling')

const UserSchema = new MONGOOSE.Schema({
    ...
})

MONGOOSE.model('User', UserSchema)

Connection

In the app entry module:

app.js
const MONGOOSE = require('mongoose-aws-documentdb-tunneling')
const MODELS = PATH.join(__dirname, 'databases/mongodb/models')

/**
 * 1. Register your models by requiring them. Here's an example to dynamicly
 * add all models within a folder.
 */
FS.readdirSync(MODELS) .filter(
        file => ~file.search(/^[^\.].*\.js$/)
    )
    .forEach(
        file => require(PATH.join(MODELS, file))
    )

/**
 * 2. Initiate the module with required options.
 */
MONGOOSE.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,
    vpcTunnelEC2PortLocal: +process.env.VPC_TUNNEL_EC2_PORT_LOCAL,
    vpcTunnelEC2PrivateKey: FS.readFileSync(
        PATH.join(__dirname, `keys/${process.env.VPC_TUNNEL_EC2_PRIVATE_KEY}`), 'utf8'
    ),
    documentdbClusterEndpoint: process.env.DOCUMENTDB_CLUSTER_ENDPOINT,
    documentdbClusterPort: +process.env.DOCUMENTDB_CLUSTER_PORT,
    documentdbClusterDbName: process.env.DOCUMENTDB_CLUSTER_DB_NAME,
    documentdbClusterUsername: process.env.DOCUMENTDB_CLUSTER_USERNAME,
    documentdbClusterPassword: process.env.DOCUMENTDB_CLUSTER_PASSWORD,
    documentdbEndpoint: process.env.DOCUMENTDB_ENDPOINT,
    documentdbPort: +process.env.DOCUMENTDB_PORT,
})
    .then(success => DEBUG(success))
    .catch(error => { throw error })

/**
 * 3. 🔥 Profit 🔥
 */

Query

users.module.js
const const { MongooseClient: MONGOOSE } = require('mongoose-aws-documentdb-tunneling')

/**
 * Get all users.
 * @returns {Promise<[<user>]>} users
 */
function getUsers() {
    return MONGOOSE
        .model('User')
        .find()
        .toArray()
}

Troubleshooting

  • ...

FAQs

Last updated on 07 Aug 2019

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc