I have a nodejs script which connects to an Oracle DB which is in a private VPC. I can run this script without any issues on my machine, and in a lambda. I need to run this from Github Action. I have stored DB_USER, DB_PASSWORD AND DB_CONNECTION in SECRETS and passing them to the js script. I am reading them as process.env…. in my script. I have verified the values. But when I try to get the connection, it never
connects and times out after 60 seconds printing this error:
Request exceeded “transportConnectTimeout” of 60 seconds.
If I have the DB credentials, but if the DB is in an AWS account in its own private VPC, do I need to do anything else to access it in Github Actions?
Thank you for any help!!
My yaml script:
name: DB Connection
on:
workflow_dispatch:
jobs:
build:
runs-on: ubuntu-latest
environment: dev
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Set up Node.js
uses: actions/setup-node@v2 # Set up Node.js
with:
node-version: '20.9'
- name: Install dependencies
run: npm install
- name: Run JS
env:
DB_USER: ${{ secrets.DB_USER }}
DB_PASSWORD: ${{ secrets.DB_PASSWORD }}
DB_CONNECTION: ${{ secrets.DB_CONNECTION }}
run: node ./src/test-db-connection.js
My JS (test-db-connection.js):
import oracledb from 'oracledb';
async function testConnection() {
let connection;
try {
connection = await oracledb.getConnection({
user: process.env.DB_USER,
password: process.env.DB_PASSWORD,
connectString: process.env.DB_CONNECTION,
});
console.log("Database connection successful!", connection);
} catch (err) {
console.error("Database connection failed:", err.message);
} finally {
if (connection) {
try {
await connection.close();
} catch (err) {
console.error('Error closing the connection:', err);
}
}
}
}
testConnection();