Home > front end >  How to fix an error after deploying project using aws cdk
How to fix an error after deploying project using aws cdk

Time:10-19

    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.

CodePudding user response:

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.

  • Related