-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Added ProgrammaticAssumeRoleProvider and Session.assume_role() for #761 #2096
Conversation
Codecov Report
@@ Coverage Diff @@
## develop #2096 +/- ##
===========================================
- Coverage 93.10% 93.09% -0.02%
===========================================
Files 60 60
Lines 11101 11128 +27
===========================================
+ Hits 10336 10360 +24
- Misses 765 768 +3
Continue to review full report at Codecov.
|
Pinging on this. Would love to make my first contribution to the Python SDK! |
Hi @benkehoe, thank you for the PR and sorry for the wait. I discussed this with the team and will share some points that came up. Currently we don’t provide public interfaces for any CredentialProviders in botocore. To support that would require a substantial refactoring of the codebase. The implementation here doesn’t follow our existing CredentialProvider workflows and involves replacing the existing credential chain with an overwritten one. That makes the session inoperable for any credentials except the ARN used to assume the role. The current change also doesn't account for the use of profiles, which means the new session will be broken for common configuration cases. For those reasons we think that currently it makes more sense for this to exist as a third-party plugin. But we may revisit this in a future refactoring or major version. |
Thanks for following up. It's true that botocore doesn't today provide programmatic credential definitions, but this is generally not true of other SDKs, e.g., JavaScript (even in v2). It's unfortunate that Python doesn't get the same capability. For the record, though, I wanted to respond to this part:
This is intentional. The explicit purpose of this credential provider is to provide a programmatic way to get a new session that uses an assumed role based on a parent session. This new session should not be able to pick up any other credentials. Such a session can only be created through Python code, not through configuration (there's already a credential provider for that). For that reason it uses a |
Hi @benkehoe thanks for sharing those points. Unfortunately the team is still not considering the proposed changes at this time. We could make changes to more tightly integrate this with the existing interfaces, but this would still be a special case feature that we’d need to maintain outside of the normal credential flow. Some SDKs may have some form of this feature as you mentioned, but generally speaking we are trying to move toward more standardization of feature implementation across SDKs. Adding another different approach here in botocore would take us further from alignment. But we will continue recommending your aws-assume-role-lib library to those who could benefit from using it. Also this PR prompted a broader team discussion on how boto3 could better support/incorporate third-party libraries and plugins such as that one. If you have any thoughts to share regarding that please let us know. |
As part of that, please, please include programmatic configuration as a standardized feature. I have one last-ditch proposal. What if we added a new
This credential provider would never get activated by existing config, and this config would never activate existing credential providers. Then that session creation would get wrapped up in a My concern with AWS recommending 3rd party libraries like |
I've been a fool. This implementation is needlessly overcomplicated, because I missed how static credentials are used in a botocore Session. If a |
Issue #761 asks for first-class support for sts:AssumeRole, where there is a
Session.assume_role()
method that produces another session (boto3.Session
would then also get anassume_role()
method). To implement this, the existingcredentials.AssumeRoleProvider
seemed too intimately tied to loading credentials from config, in particular there did not seem to be a good way of injecting an arbitraryCredentials
object, so I added a new, simplerProgrammaticAssumeRoleProvider
class that mainly just wraps theAssumeRoleCredentialFetcher
. I've replicated the unit tests forAssumeRoleProvider
except those that relate to configuration files.I'm hoping to get feedback on whether this is a contribution that can feasibly be accepted before I add the functional tests and go to the effort of figuring out how the integration testing works.