Undefined username and password from config/config.js but .github/workflows/deploy.yml sequelize config is retrieving from GitHub repo secrets

I could not get the database username and password passed to the config/config.js from .github/workflows/deploy.yml. When I pushed the codes to the GitHub. The GitHub Actions automate the deployment and ran the sequelize commands which turned out to be successful as it was getting all the secrets such as username, password, database name, and host. When I tried to have these confidential variables passed to config/config.js, the DB_NAME and DB_HOST are working but DB_USERNAME and DB_PASSWORD appeared to be undefined. I have found out about this issues when I was looking at the console log from the AWS CloudWatch because there was an error when the user is creating an account. Post confirmation basically checks the user and assign the role based on their email domain. This process requires an access to the Postgres database.

I have tried changing the variable name such as from “DB_USERNAME” to “USERNAME” and applied the same way for password, database name, and host. I have updated the variable name from deploy.yml and config/config.js. However, they all turned out to be undefined when I looked at the console logs from the CloudWatch. So, I have changed the variable names back. The username and password are undefined while the database and host show the values. I am not sure if this has to do with the naming or not.

.github/workflows/deploy.yml:

name: Deploy to AWS

on:
  push:
    branches:
      - main

permissions:
  id-token: write
  contents: read

env:
  AWS_REGION: 'us-east-1'

jobs:
  deploy:
    runs-on: ubuntu-latest

    steps:
      - name: Checkout repository
        uses: actions/checkout@v2

      - name: Set up Node.js
        uses: actions/setup-node@v2
        with:
          node-version: '20'

      - name: Install dependencies
        run: npm install

      - name: Install AWS CDK
        run: npm install -g aws-cdk

      - name: Install ts-node
        run: npm install -g ts-node

      - name: List files for debugging
        run: ls -R

      - name: Verify cdk/bin contents
        run: ls -R cdk/bin

      - name: Configure AWS credentials
        uses: aws-actions/configure-aws-credentials@v2
        with:
          role-to-assume: ${{secrets.ROLE_TO_ASSUME}}
          aws-region: ${{env.AWS_REGION }}
          role-session-name: GitHubActions

      - name: Install frontend
        working-directory: frontend/frontendapp
        run: npm install

      - name: Build frontend
        working-directory: frontend/frontendapp
        run: npm run build

      - name: CDK deploy
        run: cdk deploy --all --require-approval never --app "npx ts-node cdk/bin/cdk_test.ts"

      - name: Run Sequelize commands
        env:
          DB_USERNAME: ${{secrets.USERNAME}}
          DB_PASSWORD: ${{secrets.PASSWORD}}
          DB_NAME: ${{secrets.DATABASE}}
          DB_HOST: ${{secrets.HOST}}
        run: npx sequelize db:migrate --config config/config.js

config/config.js:

console.log("Database Config from config/config.js:");
console.log("Development Username:", process.env.DB_USERNAME);
console.log("Development Password:", process.env.DB_PASSWORD);
console.log("Development Database:", process.env.DB_NAME);
console.log("Development Host:", process.env.DB_HOST);

module.exports = {
  development: {
    username: process.env.DB_USERNAME,
    password: process.env.DB_PASSWORD,
    database: process.env.DB_NAME,
    host: process.env.DB_HOST,
    dialect: 'postgres'
  },
  test: {
    username: process.env.DB_USERNAME,
    password: process.env.DB_PASSWORD,
    database: process.env.DB_NAME,
    host: process.env.DB_HOST,
    dialect: 'postgres'
  },
  production: {
    username: process.env.DB_USERNAME,
    password: process.env.DB_PASSWORD,
    database: process.env.DB_NAME,
    host: process.env.DB_HOST,
    dialect: 'postgres'
  }
};

Thank you in advance.

New contributor

Awais Nisar is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật