Skip to content
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

Adds async methods for assuming roles #3627

Open
wants to merge 2 commits into
base: main-staging
Choose a base branch
from

Conversation

mscottford
Copy link

Adds async pathways for assuming a role.

Description

Adds async version of AssumeRoleAWSCredentials.GenerateNewCredentials and subsequent method call chain.

Motivation and Context

There was no async pathway for assuming a role. This is causing issues on platforms that do not support calling HttpClient.Send such as Android and iOS.

This should fix #3626.

Testing

All tests in UnitTests.NetStandard and AWSSDK.ProtocolTests.NetStandard pass.

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist

  • My code follows the code style of this project
  • My change requires a change to the documentation
  • I have updated the documentation accordingly
  • I have read the README document
  • I have added tests to cover my changes
  • All new and existing tests passed

License

  • I confirm that this pull request can be released under the Apache 2 license

@dscpinheiro dscpinheiro changed the base branch from main to main-staging January 29, 2025 18:31
@dscpinheiro dscpinheiro requested a review from normj January 30, 2025 17:46
@normj
Copy link
Member

normj commented Feb 14, 2025

Thanks @mscottford for the PR. We consider additions to the ICoreX interfaces as breaking changes because what has happened in the past when we did this is we make the change and the users for a variety reasons update a service package, for example S3, which pulls in the Core with this change. But nothing updates the STS package which is the implementation of the ICoreX interface in this case. Then applications start failing at the runtime for missing method implementations because Core is looking for your new method in STS that didn't get updated.

So our options are either put the async methods in a new ICoreAmazonSTSAsync interface and then have Core check to see if
the loaded STS client implements ICoreAmazonSTSAsync, if so use otherwise fallback to the existing sync method. Or target the PR to V4 where we can make this type of breaking change.

@mscottford
Copy link
Author

Ah, that makes sense. I'll take a stab at adding a new interface. Is that something that you'd like to see in a separate PR or as commits to this one?

@mscottford
Copy link
Author

And do you have any guidance for the best way to go about adding tests for the logic that determines when to use the async path? I didn't find any tests for the AssumeRoleAWSCredentials.GenerateNewCredentials method.

@normj
Copy link
Member

normj commented Feb 21, 2025

As long as you targeting V3 then adding the ICoreAmazonSTSAsync interface in this PR makes sense.

As for tests do mean how to fallback to previous sync interface if the async interface is not around? If so unfortunately our tests are only setup for testing the tip of the codebase which of course would always have the async version. We have checks in our build system that look out for when we attempt breaking changes like this. In your case we would need to do the mix version tests manually and then add the exception in our validation checker.

* Moves the definition of `CredentialsFromAssumeRoleAuthenticationAsync` into the new interface.
* Only attempts to call `CredentialsFromAssumeRoleAuthenticationAsync` if the STS client instance implements `ICoreAmazonSTSAsync`.
@mscottford
Copy link
Author

@normj New interface has been added and it is only called if the ICoreAmazonSTS reference also implements ICoreAmazonSTSAsync. Otherwise, it falls back to the previous behavior which is to just use ICoreAmazonSTS.

I also added a log message to indicate that the AWSSDK.Core package needs to be updated in the event that the fallback codepath is taken.

All unit and protocol tests are passing, but I'm unsure how to do any more thorough testing with my limited understanding of the project.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

DescribeTagsAsync can take a sync path resulting in a PlatformNotSupportedException exception on .NET Android
2 participants