55 "errors"
66 "fmt"
77 "os"
8- "os/exec"
98 "strconv"
109
1110 "github.com/aws/aws-sdk-go/aws"
@@ -17,6 +16,7 @@ import (
1716
1817 "github.com/alecthomas/kong"
1918 "github.com/aws/aws-sdk-go/aws/session"
19+ "github.com/skratchdot/open-golang/open"
2020)
2121
2222type Context struct {
@@ -80,17 +80,12 @@ func (cli *Console) consoleURL(signinToken string, destinationURL string) string
8080 return consoleURL .String ()
8181}
8282
83- // Credentials will only work with one of the latest versions of the AWS Go SDK (see go.mod)
84- // 1.40.26 was found to work. Versions < 1.40.x would not read profiles that were kept in
85- // ~/.aws/config but only looked at ~/.aws/credentials
8683func (cli * Console ) Credentials (profile string ) (credentials.Value , string , error ) {
8784 var sess * session.Session
8885
8986 if profile != "" {
9087 sess = session .Must (session .NewSessionWithOptions (session.Options {
9188 Profile : profile ,
92- // according to some otherwise unrelated Github Issue
93- SharedConfigState : session .SharedConfigEnable ,
9489 }))
9590 } else {
9691 sess = session .Must (session .NewSessionWithOptions (session.Options {
@@ -145,19 +140,9 @@ func (cli *Console) Run(ctx *Context) error {
145140 return nil
146141 }
147142
148- // Have to run the browser "by hand", because of a discovered issues with AWS CLI v2 env vars
149- c := exec .Command ("xdg-open" , consoleURL )
150- // This is set somewhere in the framework to only the AWS CLI V2 dist path
151- // to the exclusion of everything else.
152- os .Unsetenv ("LD_LIBRARY_PATH" )
153- c .Env = os .Environ ()
154- out , err := c .Output ()
143+ err = open .Run (consoleURL )
155144 if err != nil {
156- if string (out ) == "" {
157- e := err .(* exec.ExitError )
158- out = e .Stderr
159- }
160- return fmt .Errorf ("error while opening browser, %s" , out )
145+ return fmt .Errorf ("error while opening browser, %s" , err )
161146 }
162147
163148 return nil
0 commit comments