Configure a Resource from code

Is it possible to configure a resource from code i.e. with environment variables or mapped config file?

I have an scenario where i want to setup a DB resource in retool. the retool instance is in a private subnet, with access to a private DB. all the db credentials are managed in Terraform, so it feels logical to pass then to retool programatically as well.

I've found that i can expose variables, which is a partial solution as it still requires a human to setup the resource (and manage any changes)