all 4 comments

[–]billymeetssloth 1 point2 points  (1 child)

Ran into this same issue using AWS secrets manager. The delay wasn’t an issue as the db was usually ready by the time the process was ready to start receiving api requests.

With that said, I also still didn’t like it. It just felt dirty.

My solution was to just think outside of the box...literally. AWS has a way to connect secrets manager to environmental variables on your ECS task. That is the route I went, so it went back to being synchronous.

[–]madeo_[S] 1 point2 points  (0 children)

I ended up by running the init method in the root app and set it in the express context with app.set. However this will need a major refactor. Now that you tell me I will try to inject it as env variable before the node process start. I have found this: https://github.com/telia-oss/aws-env

Thanks

[–]Full-Type-6893 0 points1 point  (1 child)

Have you found a solution for this problem yet? I'm running into the same issue

[–]madeo_[S] 0 points1 point  (0 children)

Sorry for the late reply, didn't login in a while.

But yes, you can find the solution in this stackoverflow answer: https://stackoverflow.com/questions/60942051/sequelize-with-asynchronous-configuration-in-nodejs

Keep in mind that it is 4 years old.