Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Need to work around Windows is lacking eval equivalent #188

Closed
synfinatic opened this issue Dec 21, 2021 · 1 comment · Fixed by #495
Closed

Need to work around Windows is lacking eval equivalent #188

synfinatic opened this issue Dec 21, 2021 · 1 comment · Fixed by #495
Labels
bug Something isn't working help-wanted Extra attention is needed
Milestone

Comments

@synfinatic
Copy link
Owner

synfinatic commented Dec 21, 2021

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?

@synfinatic synfinatic added bug Something isn't working help-wanted Extra attention is needed labels Dec 21, 2021
synfinatic added a commit that referenced this issue Dec 21, 2021
- Can't use `eval` with Windows (#188)
- Default to `cmd.exe` for `exec` on Windows
- Detect invalid accountId with -A flag
- Improve docs for Windows in FAQ
synfinatic added a commit that referenced this issue Dec 21, 2021
- Can't use `eval` with Windows CommandPrompt/PowerShell (#188)
- Default to `cmd.exe` for `exec` on Windows
- Detect invalid accountId with -A flag
- Improve docs for Windows in FAQ
synfinatic added a commit that referenced this issue Dec 21, 2021
- Can't use `eval` with Windows CommandPrompt/PowerShell (#188)
- Default to `cmd.exe` for `exec` on Windows
- Detect invalid accountId with -A flag
- Improve docs for Windows in FAQ
- Fully fix bogus wincred error in last PR
@AHoran
Copy link

AHoran commented Jul 21, 2022

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"

synfinatic added a commit that referenced this issue Jul 29, 2023
PowerShell requires a slightly different output of environment
variables than bash/zsh/etc.

Updated docs to refelect how to use `eval` with PowerShell.

Bump to v1.10.0

Fixes: #188
@synfinatic synfinatic added this to the next release milestone Jul 29, 2023
synfinatic added a commit that referenced this issue Jul 29, 2023
PowerShell requires a slightly different output of environment
variables than bash/zsh/etc.

Updated docs to refelect how to use `eval` with PowerShell.

Bump to v1.10.0

Fixes: #188
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working help-wanted Extra attention is needed
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants