Issue
import * as tedious from "tedious"
const { Sequelize } = require("sequelize");
const sequelize = new Sequelize({
"dialect": "mssql",
"dialectModule": tedious,
"dialectOptions": {
"driver": "SQL Server Native Client 11.0",
"trustedConnection": true
},
"username": process.env.USER_NAME,
"password": process.env.PASSWORD,
"database": process.env.DATABASE,
"host": process.env.SERVER,
"port": 1433,
"logging": console.log,
"pool": {}
})
(async () => {
await sequelize.authenticate()
console.log('authentication success')
})().catch(err => {
console.log("sequelize auth error:", err.message)
})
locally works fine but after deploy to aws it crashes with this error: INFO sequelize auth error: The "config.server" property is required and must be of type string.
Solution
It looks like env variables are not available in the environment where you run the app. If it is a Lambda function, make sure you passed env variables in the related CDK Construct.
P.S. I'd recommend also using AWS secret manager for storing sensitive variables like passwords.
Answered By - Artem Arkhipov Answer Checked By - Mary Flores (PHPFixing Volunteer)
0 Comments:
Post a Comment
Note: Only a member of this blog may post a comment.