PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Thursday, October 20, 2022

[FIXED] How to fix an error after deploying project using aws cdk

 October 20, 2022     amazon-web-services, node.js, sequelize.js     No comments   

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)
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing