Skip to content

Commit

Permalink
aws/credentials/stscreds: Update StdinTokenProvider to prompt on stder (
Browse files Browse the repository at this point in the history
aws#2481)

Updates the `stscreds` package default MFA token provider, `StdinTokenProvider`, to prompt on `stderr` instead of `stdout`. This is to make it possible to redirect/pipe output when using `StdinTokenProvider` and still seeing the prompt text.
  • Loading branch information
thrawny authored and jasdel committed Mar 20, 2019
1 parent fbb5ad0 commit 5468300
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions aws/credentials/stscreds/assume_role_provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ package stscreds

import (
"fmt"
"os"
"time"

"github.com/aws/aws-sdk-go/aws"
Expand All @@ -89,7 +90,7 @@ import (
"github.com/aws/aws-sdk-go/service/sts"
)

// StdinTokenProvider will prompt on stdout and read from stdin for a string value.
// StdinTokenProvider will prompt on stderr and read from stdin for a string value.
// An error is returned if reading from stdin fails.
//
// Use this function go read MFA tokens from stdin. The function makes no attempt
Expand All @@ -102,7 +103,7 @@ import (
// Will wait forever until something is provided on the stdin.
func StdinTokenProvider() (string, error) {
var v string
fmt.Printf("Assume Role MFA token code: ")
fmt.Fprintf(os.Stderr, "Assume Role MFA token code: ")
_, err := fmt.Scanln(&v)

return v, err
Expand Down

0 comments on commit 5468300

Please sign in to comment.