auths
objectreturn
or this.key = 'value'
, pass input data to your code viaparams
, and maintain state across executions with$checkpoint.async
(event, steps, auths) => {
}
const { Client } = require('pg')
const SSH2Promise = require('ssh2-promise')
const { user, password, port, database } = auths.postgresql
const { host, username, privateKey } = auths.ssh
const ssh = new SSH2Promise({
host,
username,
privateKey,
})
const tunnel = await ssh.addTunnel({
remoteAddr: auths.postgresql.host,
remotePort: auths.postgresql.port,
})
const client = new Client({
host: 'localhost',
port: tunnel.localPort, // local tunnel port
user,
password,
database,
})
await client.connect()
this.results = (await client.query("SELECT NOW()")).rows
await client.end()
await ssh.close()