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

For automation needs, have a similar UrlAction print but only printing the url on stdout - without any pre / post text #303

Closed
llange opened this issue Mar 11, 2022 · 3 comments · Fixed by #306
Labels
enhancement New feature or request
Milestone

Comments

@llange
Copy link

llange commented Mar 11, 2022

Is your feature request related to a problem? Please describe.
It's a minor annoyance, I have a workaround.
I'd like to automate the opening of some AWS console sessions in tabs (containers), so that those sessions are isolated in the browser.
I'm using this extension https://github.com/honsiorovskyi/open-url-in-container which provides the ability to launch an URL in a specific container tab (and a cli launcher).
However the current implementation of the print UrlAction of aws-sso has 2 "issues":

  • It outputs to stderr
  • It prints some text before and after the url ("Please open the following URL in your browser:").

thus I need to post-process the (stderr) output of aws-sso console to extract the url.
(And I cannot use the --browser argument as it's not intended to have parameters).

I thought it could be nice to have a full non-interactive output for automation.
I like the idea of each tool doing its own job, and chaining the output / result of the tools to compose a solution (Instead of having too much features in a tool).

Describe the solution you'd like

  • Either an additional option --url-action=XXXXX, or a decision to remove all the accompanying text when using --url-action=print (which may be inconvenient to existing users)
  • All useful data should go to stdout
    (May be a solution could be to print the accompanying text to stderr, while the data itself is output to stdout ; there may be a risk in display order).

Describe alternatives you've considered
Currently I'm post-processing stderr to extract the URL:

aws-sso console --arn arn:aws:iam::XXXXXXXXXXXXX:role/YYYYYYYYYYYY --url-action=print 2>&1 | sed -ne 's/\(http[^"]*\).*/\1/p' | xargs firefox-launcher (args) (args)

which works great.

@llange llange added the enhancement New feature or request label Mar 11, 2022
@synfinatic
Copy link
Owner

so the --url-action=print command can't print anything to stderr because that will interfere with things like eval $(aws-sso eval ...) to load the AWS creds into the existing shell environment.

That said, I can create a new --url-action which only prints the url without the accompanying text for easier integration (remove the sed), but I think it should still go to stderr because of the above.

Is that a reasonable compromise?

@llange
Copy link
Author

llange commented Mar 12, 2022

Hi,
thanks for the answer ; and yes, it does sound like an interesting addition, thanks !!
Let me know how I can help on this.

synfinatic added a commit that referenced this issue Mar 19, 2022
Add additional url actions to print only the url or execute
an arbitrary command to make it easier to itegrate with other
tools/browsers

Fixes: #303
synfinatic added a commit that referenced this issue Mar 21, 2022
Add additional url actions to print only the url or execute
an arbitrary command to make it easier to itegrate with other
tools/browsers

Fixes: #303
synfinatic added a commit that referenced this issue Mar 21, 2022
Add additional url actions to print only the url or execute
an arbitrary command to make it easier to itegrate with other
tools/browsers

Fixes: #303
synfinatic added a commit that referenced this issue Mar 21, 2022
Add additional url actions to print only the url or execute
an arbitrary command to make it easier to itegrate with other
tools/browsers

Fixes: #303
synfinatic added a commit that referenced this issue Mar 21, 2022
Add additional url actions to print only the url or execute
an arbitrary command to make it easier to itegrate with other
tools/browsers

Fixes: #303
synfinatic added a commit that referenced this issue Mar 21, 2022
Add additional url actions to print only the url or execute
an arbitrary command to make it easier to itegrate with other
tools/browsers

Fixes: #303
synfinatic added a commit that referenced this issue Mar 21, 2022
Add additional url actions to print only the url or execute
an arbitrary command to make it easier to itegrate with other
tools/browsers

Fixes: #303
synfinatic added a commit that referenced this issue Mar 21, 2022
Add additional url actions to print only the url or execute
an arbitrary command to make it easier to itegrate with other
tools/browsers

Fixes: #303
@synfinatic synfinatic added this to the Next Release milestone Mar 24, 2022
@synfinatic
Copy link
Owner

@llange: just a follow up, if you get a chance, check out the new exec feature I added. I think that should be an even better solution to the printurl option we discussed. LMK if you have any questions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants