Serverless env variables and Sequelize migrations config (yml vs js)

I’m using Aurora DB and sequelize ORM library to work with it.
The credentials to access DB is stored in env.yml file which is included in serverless.yml like this:

environment: ${file(env.yml):${self:provider.stage}}

lambdas work fine in this way. But we also have few scripts in package.json to manage our BD migrations:

"scripts": {
    "migrate": "sequelize db:migrate",
    "unmigrate": "sequelize db:migrate:undo",
    "unmigrate:all": "sequelize db:migrate:undo:all",
    "seed": "sequelize --models-path src/models db:seed:all --debug",
  },

the problem is that when you run sequelize migrations locally, it requires a config.js file with connection parameters while I keep them in yml file.

Currently I see two way to fix this embarrassment:

  1. to create a lambdas that will run those npm commands using DB creds from serverless.yml
  2. to create a script that will get creds from serverless.yml and run migration with those creds

So how good/bad to have lambdas for such a maintain purposes?

1 Like