-
Notifications
You must be signed in to change notification settings - Fork 669
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
AssumeRoleOptions does not have TokenCode member #1384
Comments
Thanks for raising this documentation issue, the correct structure field to use is https://pkg.go.dev/github.com/aws/aws-sdk-go-v2/credentials/stscreds#hdr-Assume_Role_with_MFA_Token_Provider has a correct example usage for this. We will work on getting this addressed and updated. |
I'm not sure if it's purely documentation. There's still a strong use case for static TokenCode. It looks like TokenProvider opens up STDIN to read a token, but if you were to run this is thousands of go routines (at least till that MFA code expire). It wouldn't be a scalable method. Because you would have to enter the MFA code thousands of times |
Thanks for the update @NukaCody. We'll work to get the documentation for this updated. The StdinTokenProvider is a basic implementation of the TokenProvider provided by the SDK for reading token from stdin, but it is very limited and is not configurable. Instead of using the SDK provided cfg, err := config.LoadDefaultConfig(context.TODO())
if err != nil {
panic(err)
}
// Use a custom function to provide the token for assume role credential provider.
staticTokenProvider := func() (string, error) {
return "someCode", nil
}
// Create the credentials from AssumeRoleProvider to assume the role
// referenced by the "myRoleARN" ARN using the MFA token code provided.
creds := stscreds.NewAssumeRoleProvider(sts.NewFromConfig(cfg), "myRoleArn", func(o *stscreds.AssumeRoleOptions) {
o.SerialNumber = aws.String("myTokenSerialNumber")
o.TokenProvider = staticTokenProvider
})
cfg.Credentials = aws.NewCredentialsCache(creds)
// Create service client value configured for credentials
// from assumed role.
svc := s3.NewFromConfig(cfg) |
Fixes the AssumeRoleProvider's documentation for using custom TokenProviders. Fixes aws#1384
|
Confirm by changing [ ] to [x] below to ensure that it's a bug:
Describe the bug
AssumeRoleOptions does not have a TokenCode member despite documentation using it as an example for static MFA token
Version of AWS SDK for Go?
1.8.0
Version of Go (
go version
)?go version go1.16.6 darwin/amd64
To Reproduce (observed behavior)
Steps to reproduce the behavior (please share code or minimal repo)
Expected behavior
A clear and concise description of what you expected to happen.
Get MFA token at the entry point of the app, then spin up hundreds of goroutines that assume roles into different accounts that have MFA required using the static token code. Moving StdinTokenProvider inside of the goroutine won't be goroutine safe nor scalable
The text was updated successfully, but these errors were encountered: