SHARE
TWEET

Untitled

a guest Jun 17th, 2019 90 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. exports.handler = function(context, event, callback) {
  2.     const tunnel = require('tunnel-ssh');
  3.     const { Client } = require('pg');
  4.  
  5.     const sshUserName = 'ec2user';
  6.     const sshPassword = 'EC2-pwd';
  7.  
  8.     let sshConfig = {
  9.         host: 'ecx-xxx-xxx.compute-1.amazonaws.com',
  10.         port: 22,
  11.         username: sshUserName,
  12.         password: sshPassword,
  13.         keepaliveInterval: 60000,
  14.         keepAlive: true,
  15.         dstHost: 'some-name-for-db.us-east-1.rds.amazonaws.com',
  16.         dstPort: 5432
  17.     };
  18.  
  19.  
  20.     let dbConfig =  {
  21.         host: 'some-name-for-db.us-east-1.rds.amazonaws.com',
  22.         port: 5334,
  23.         user: 'user',
  24.         password: 'some-password',
  25.     };
  26.  
  27.     const tnl = tunnel(sshConfig, function (error, server) {
  28.         if (error) {
  29.             throw error;
  30.         }
  31.         const client = new Client(dbConfig);
  32.         // do something with db
  33.     });
  34. };
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top