Can I create global environmental variables for RStudio Connect applications?

My company has dozens of Shiny apps deployed in our RStudio Connect environment. In recent months we've tried to improve our coding practices, moving all sensitive data into environmental variables, and setting these variables individually for each app in Connect's Environmental Variables form:
image

However, it feels very manual to need to add these for each app where 99% of the time they'll be using variables (i.e. DB_HOST, DB_USER, DB_PASS).

For now I use Studio Connects supervisor script to add these variables to the global environment, but it feels a bit hacky to me, and I was wondering if there was a way to create global environmental variables directly through the UI?

1 Like

Howdy @mmccarthy404 ! We unfortunately do not have such a feature available presently.

However, I am happy to pass this along to the engineering team for consideration!

Further, it may be worth taking a look at the connectapi package, which has a function for setting environment variables. As a result, you could always write your own script for setting environment variables easily.

It's worth noting that changing environment variables does restart the app, so it would affect users currently using the app. This is much less hacky than the supervisor script, though, because it is not truly global in the sense that it affects all pieces of content simultaneously. :smile:

Definitely not a perfect solution, but could be used with CI / RStudio Add-Ins / other workflow optimizers to make your life easier, perhaps :smile: