feat: option to assume role to get credentials#6
Conversation
|
Thanks for making this contribution! I agree that having the option to assume a role would be a good addition to the accepted configuration keys: using temporary credentials is a much better option than static access/secret keys. |
jmkeyes
left a comment
There was a problem hiding this comment.
/lgtm
The whitespace changes in the diff of the test code made things a bit harder to read, but I can run black later if needed.
|
Not strictly relevant to the PR, but the AWS SDK can also assume a role if configured to do so. While it is nice to explicitly configure it ourselves here, it begs the question of how much responsibility this library should take in replicating that logic. This also ties into #8: where do we draw the line between the behaviour of this library (via configuration) and the implicit behaviour of the |
We have a considerable number of profiles and AWS child accounts that require cross-account authentication. Tightly coupling IAM configuration between identity roles and resource access can become difficult (one reason being IAM policy size limits) and keeping our identity roles loosely coupled from some resource access roles makes maintenance easier. We could have additional configuration settings for the AWS SDK to assume the roles, but all the combinations we have would create an explosion of configuration entries. Being able to have loose coupling between the identity roles we use and resource roles in the configuration for this library makes management of all these things much simpler for our users. |
I agree. The first use case for this keyring backend had very little need for configuration at all. While it is convenient to define access/secret keys in the For version 3.x of this backend, I'm tempted to drop support for specifying access/secret keys in configuration and explicitly require users to migrate them to This would substantially limit the configuration options that this library needs to be aware of. |
|
@jmkeyes does this look good to merge? |
Almost! Here are some thoughts:
Let me know what you think! |
When fetching credentials after obtaining the boto3 session, we check if the configuration has an optional `assume_role` field, which indicates that role needs to be assumed to obtain the credentials. If found, the role is assumed and used to obtain the credentails. If not the original boto3 session is used to obtain the credentials.
|
@jmkeyes coming back to this finally. I have addressed your comments, and rebased on top of the latest changes. If a session name is not provided we will use the |
When fetching credentials after obtaining the boto3 session, we check if the configuration has an optional
assume_rolefield, which indicates that role needs to be assumed to obtain the credentials.If found, the role is assumed and used to obtain the credentails. If not the original boto3 session is used to obtain the credentials.