Where is the application db connection logic located in code base

Hi there:
We're actively using self-hosted Metabase as out data visualization platform and it works well and gives much help. We have AWS RDS Postgres db as the MB application database. The db user name and password are passed as environmental variables to Metebase.

But recently we're focusing on the migration to use IAM-based connection to all RDS databases; thus all password shouldn't appear in our codebase, event that it's encrypted version. I have implemented the logic to connect to the data sources with IAM-based connection on Metabase, but for its own application db, haven't figured out how to deal with it.
Can anyone point me to where that connection logic is located in Metabase codebase? And any luck I could make this change without huge amount of changes?

Thanks