Pattern for Dev -> Prod Secret Managemnt

Product: PowerShell Universal
Version: 3.4.6

Development:
Git: Two-Way
$env:psuEnv = "dev"

Production: 
Git: One-Way
$env:psuEnv = "prod"

If i add a secret that can only be used in Dev, and i add a secret that can only be used in Prod, is there a solution to reference the correct secret depending on the machine that it is being run from.

It would make sense maybe if we had a cmdlet that did something like this:

$myEnvParm = Get-PSUVariable -Name "$($env:psuEnv)SQLServer"
$myEnvCred = Get-PSUSecret -Name "$($env:psuEnv)SQLCred"

Maybe there is already provisions made for deployment environments like Dev/Stage/Prod?

1 Like

@Omzig That would depend on your existing set up. Are you using PowerShell Universal’s built-in vault? If you are, a solution I use is to create a variable in PSU in each environment, and set the variable name the same in each environment, but different values for each environment. I just call the name of the variable from my script and the script doesn’t have to know which environment it’s running in.

1 Like