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 mysql = require('mysql2/promise')
const SSH2Promise = require('ssh2-promise')
const { host, username, privateKey } = auths.ssh_password_based_auth
const ssh = new SSH2Promise({
host,
username,
privateKey,
})
const tunnel = await ssh.addTunnel({
remoteAddr: auths.mysql.host,
remotePort: auths.mysql.port,
})
const connection = await mysql.createConnection({
host: 'localhost',
port: tunnel.localPort, // local tunnel port
user: auths.mysql.username,
password: auths.mysql.password,
database: auths.mysql.database,
});
const [rows, fields] = await connection.execute("SELECT NOW()")
console.log(rows)
await connection.end()
await ssh.close()