feat: add cross-account IAM role support for S3 operations and update docs/tests#519
Conversation
|
Hi, it seems that our CI build is failing after the dependency packages were updated. |
a065ddc to
6528595
Compare
@skxeve |
skxeve
left a comment
There was a problem hiding this comment.
Overall, the logic looks good, but I've left a few comments with some refactoring suggestions.
Please take a look and either make the changes or let me know your thoughts on them. I look forward to your response.
| "Either access_key and secret_key or profile path can be specified." | ||
| ) | ||
|
|
||
| if role_arn and (access_key or secret_key or profile): |
There was a problem hiding this comment.
I understand you'd like to check for a state where only one of three is specified. Is that correct?
In Python, since a bool is also an int, it would be smarter to check the three boolean conditions at once, like A + B + C == 1.
There was a problem hiding this comment.
Thanks! Your interpretation is correct.
I updated the validation to allow “at most one” auth method (zero or one). access_key+secret_key count as one, and profile and role_arn each count as one. Does this match your intent?
| aws_session_token=credentials["SessionToken"], | ||
| ) | ||
|
|
||
| def _get_cross_account_resource(self): |
There was a problem hiding this comment.
This function seems to share a lot of logic with the preceding _get_cross_account_client function.
Wouldn't it be better to refactor them into a single function and use a parameter to handle the different cases? If there's a reason for keeping them separate, I'd appreciate it if you could let me know.
There was a problem hiding this comment.
Thanks for calling this out — you’re right, these two functions share most of the logic.
I’ve refactored to extract the common part into a helper that builds the cross-account session, and then use a single function that switches by a parameter.
|
LGTM! Thank you for your contribution. |
Brief
role_arn/external_id)Points to Check
role_arnmust not be combined with keys or profileTest
external_id):Review Limit
Fixes: #462