just icon indicating copy to clipboard operation
just copied to clipboard

how to load environment variables from a secrets manager ?

Open Geczy opened this issue 2 years ago • 4 comments

currently i always have to do:

doppler run -- just <command>

i would like to just do:

just <command>

and somewhere in the justfile it will load the doppler variables, how can i do this?

https://github.com/dotabod/backend/blob/master/justfile

related: https://github.com/casey/just/issues/945#issuecomment-1126410263

Geczy avatar Jan 27 '23 15:01 Geczy

You should be able to setup your command in question in a hidden recipe and have a public recipe call it with the integration environment

# Public Integration Recipe
command:
	doppler run -- just _command

# Hidden Actual Recipe
_command:
	# all the code...

runeimp avatar Feb 14 '23 10:02 runeimp

unfortunately that doesn't work me.

just command gives me Doppler Error: Invalid Auth token. However if I type doppler run -- just _command in the terminal it works fine

cortopy avatar Oct 16 '24 17:10 cortopy

I wish we had a general solution for these kinds of thing. This is an instance of the more general problem that you cannot run a command which exports variables, and then have those variables exported to your just recipes.

In this case, can you have doppler export secrets to a .env file, which just then loads?

casey avatar Oct 30 '24 22:10 casey

Interested in native solution too.

For now I use following trick around (in Just file):

DBURL_STAGE := "$(shell doppler secrets -p <PROJECT> -c <ENVIRONMENT> get <SECRET> --plain)"

and load all needed secrets same way.

Then in some target:

deploy:
    echo "{{DBURL_STAGE}}"

Not very comfortable, but very flexible. I can access few environment ar once.

swasher avatar Mar 10 '25 07:03 swasher