-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Assuming a role from a profile with MFA is not possible #1480
Comments
There are some discussions within the team as to how we can integrate the default credential provider chain with MFA - it's a bit of a difficult issue since it requires an interrupt or extra handler to consume the MFA token value. In the meantime, Aws::AssumeRoleCredentials should work for MFA roles. |
AssumeRoleCredentials doesn't have a way to read the role and source profile from an AWS profile, so it does not help for the case of assuming a role from a profile with MFA. It does work when you know the role, MFA serial, and source credentials in advance though. I don't particularly mind whether the default credential provider supports prompting for MFA, as long as it's possible to get the |
Adding to feature request backlog. I'm definitely open to a PR which adds a method that does this (and takes the MFA token as a param). |
The
CredentialProviderChain
supports assuming a role from a profile if the profile section in~/.aws/config
has therole_arn
andsource_profile
settings.However, if the profile contains
mfa_serial
(because the IAM role requires MFA to assume) then it appears to not be possible to provide thetoken_code
parameter for the MFA call.Simply trying to use the profile fails with an error "MultiFactorAuthentication failed, must provide both MFA serial number and one time pass code."
Attempting to pass the
token_code
parameter toAws.config
results in an error "invalid configuration option `:token_code'" when making an API call:This appears to be because
CredentialProviderChain
has no way to provide thetoken_code
parameter toSharedConfig.assume_role_credentials_from_config
, andSharedConfig.assume_role_from_profile
doesn't defaulttoken_code
to anything fromAws.config
so the token code is left completely unset.Using
SharedConfig.assume_role_credentials_from_config
works perfectly, but theSharedConfig
is marked as private so I presume this is discouraged.The text was updated successfully, but these errors were encountered: