aws-sso-cli
aws-sso-cli copied to clipboard
Need to work around Windows is lacking `eval` equivalent
TL;DR: Windows CommandPrompt & PowerShell have no equivalent of bash's eval
command so you can't do eval $(aws-sso eval ...)
and have it update the environment variables for the current shell/CommandPrompt.
Using setx
is not viable either.
The only way I see to do this right now is to generate a batch script that the user can run and then it would delete itself. But this means we would write the AWS secrets to disk which is violating the basic premise of aws-sso. Need to figure out if there is another way to do this?
In powershell there is an equivalent to eval, and it's Invoke-Expression. It can be chained, so something like this should work: aws-sso eval -p 1234:role | Out-String | Invoke-Expression
The Out-String
is required to convert the object output to a string (I think).
The environment variables would be output in this style:
$Env:AWS_ACCESS_KEY_ID = "zzzz"
$Env:AWS_SECRET_ACCESS_KEY = "zzzz"
$Env:AWS_SESSION_TOKEN = "zzzz"