roby.elan
roby.elan

Reputation: 144

SQL Server database access issue from AWS Lambda

I'm getting this error while accessing SQL Server database from aws-lambda. Everything works fine from local machine.Only having access issue when executing the code from lambda.

ConnectionError: Failed to connect to 10.2.3.44\SQLSRVR code: ETIMEOUT

This is my code snippet, any help would be appreciated!

const { Sequelize } = require('sequelize');
const sequelize = new Sequelize('DBname', null, null, {
  dialect: 'mssql',
  host: '10.2.3.44',   //MSSQL Server IP sample
  dialectOptions: {
    authentication: {
      type: 'ntlm',
      options: {
        domain: 'addidas',
        userName: "uname",
        password: "pwd"
      }
    },
    options: {
      instanceName: 'SQLSRVR'
    }
  }
})
async function connect() {
    try {
      await sequelize.authenticate();
      console.log('Connection has been established successfully.');
    } catch (error) {
      console.error('Unable to connect to the database:', error);
    }
  }
connect();

Upvotes: 0

Views: 956

Answers (1)

roby.elan
roby.elan

Reputation: 144

It was because of the network restrictions only, as assumed. So had to assign lambdas in the same network which SQL server is hosted. Thanks for all the suggestions.

Upvotes: 1

Related Questions