Changing database configuration at runtime

I retrieve my database password from AWS Secrets Manager for security. As such, I’d like to configure my Slick db connection at runtime, but so far I’ve seen no way to do that. In fact the configuration is immutable, if I’m not mistaken. How is this done?

1 Like

Hi @jcabraham,

it is not possible using off the shelf play tools to rotate the configuration of the database connection.

(edit: added) the usual approach is to restart the process when new credentials are provided. The assumption is that credential rotation happen once every month (?), or three months (?), so creating a new instance next to the running one and then taking down the old one (once the new one has warmed up) is usually enough.


I don’t use Slick as I am using MongoDB with my project, so I am not sure about Slick’s capabilities, but I have database connection “swapping” where connections get created/updated at runtime (e.g. a new tenant is created), which sounds similar. That however, is custom code using the database driver and library to enable this.

Alternatively, @ignasi35’s suggestion could also work, if you put a load balancer at the front, and since Play is stateless by default, you can have a blue/green deployment update so users will not experience any downtime as you restart your process. That is what I do so app updates will not cause any downtime.