-
Notifications
You must be signed in to change notification settings - Fork 965
Accept and use the new AWS Credentials interfaces #3829
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
Accept and use the new AWS Credentials interfaces #3829
Conversation
In AwsClientBuilder and other places where customers used to be able to provide AwsCredentialsProvider.
342c987 to
8ac22a4
Compare
...test/resources/software/amazon/awssdk/codegen/poet/client/test-endpoint-discovery-async.java
Show resolved
Hide resolved
core/auth/src/main/java/software/amazon/awssdk/auth/credentials/CredentialUtils.java
Show resolved
Hide resolved
core/auth/src/main/java/software/amazon/awssdk/auth/credentials/CredentialUtils.java
Outdated
Show resolved
Hide resolved
| // TODO: Can the type be changed to IdentityProvider? This class is @SdkProtectedApi | ||
| public static final ExecutionAttribute<AwsCredentials> AWS_CREDENTIALS = new ExecutionAttribute<>("AwsCredentials"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We might be able to get away with it if we did a minor version bump and told customers we'll be breaking protected APIs, but we probably want to save that until the Smithy code generator migration, where we'll likely have to start breaking a lot of protected things.
For now, is there a way to add an AWS_CREDENTIALS_IDENTITY and support both of them? (AWS_CREDENTIALS for old consumer versions and AWS_CREDENTIALS_IDENTITY for new ones?) We could add a TODO comment or annotation for these things we want to clean up with the Smithy code generator migration so that we can make sure we don't forget them?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm, I put this comment as I thought I may make some changes to signer code to accept the new types as part of this PR, but Anna-Karin and I decided we can tackle that in part of the signer changes. And for now using toCredentials when interfacing with the signer code. As part of signer changes we can add AWS_CREDENTIALS_IDENTITY and support both, with a TODO comment as you said. For now, same comment applies to AwsClientOption.AWS_CREDENTIALS I think, so added a TODO there. Using a // smithy codegen TODO: convention. LMK if you have a different suggestion for that.
core/aws-core/src/main/java/software/amazon/awssdk/awscore/AwsRequestOverrideConfiguration.java
Outdated
Show resolved
Hide resolved
...ain/java/software/amazon/awssdk/services/polly/internal/presigner/DefaultPollyPresigner.java
Outdated
Show resolved
Hide resolved
services/rds/src/main/java/software/amazon/awssdk/services/rds/DefaultRdsUtilities.java
Show resolved
Hide resolved
services/rds/src/main/java/software/amazon/awssdk/services/rds/DefaultRdsUtilities.java
Outdated
Show resolved
Hide resolved
services/rds/src/main/java/software/amazon/awssdk/services/rds/DefaultRdsUtilities.java
Outdated
Show resolved
Hide resolved
.../main/java/software/amazon/awssdk/services/rds/model/GenerateAuthenticationTokenRequest.java
Outdated
Show resolved
Hide resolved
gosar
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There are a few comments from Matt still pending, but responding with some here.
core/auth/src/main/java/software/amazon/awssdk/auth/credentials/CredentialUtils.java
Show resolved
Hide resolved
core/auth/src/main/java/software/amazon/awssdk/auth/credentials/CredentialUtils.java
Outdated
Show resolved
Hide resolved
core/aws-core/src/main/java/software/amazon/awssdk/awscore/AwsRequestOverrideConfiguration.java
Outdated
Show resolved
Hide resolved
core/aws-core/src/main/java/software/amazon/awssdk/awscore/AwsRequestOverrideConfiguration.java
Outdated
Show resolved
Hide resolved
core/aws-core/src/main/java/software/amazon/awssdk/awscore/AwsRequestOverrideConfiguration.java
Outdated
Show resolved
Hide resolved
...ore/src/main/java/software/amazon/awssdk/awscore/client/builder/AwsDefaultClientBuilder.java
Show resolved
Hide resolved
| return config.option(AwsClientOption.CREDENTIALS_PROVIDER) != null | ||
| ? config.option(AwsClientOption.CREDENTIALS_PROVIDER) | ||
| private IdentityProvider<? extends AwsCredentialsIdentity> resolveCredentialsIdentityProvider(SdkClientConfiguration config) { | ||
| // Note, that CREDENTIALS_PROVIDER is never set. It is replaced with CREDENTIALS_IDENTITY_PROVIDER, so just check that |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm, given your comment above, for older clients, we need to set CREDENTIALS_PROVIDER, so putting this comment at the definition of the option would be confusing. Given the comment above, I'm going to remove this comment here and instead add a comment above explaining why CREDENTIALS_PROVIDER is being set. LMK if you think I should comment things differently.
...ore/src/main/java/software/amazon/awssdk/awscore/client/builder/AwsDefaultClientBuilder.java
Outdated
Show resolved
Hide resolved
...in/java/software/amazon/awssdk/awscore/internal/client/config/AwsClientOptionValidation.java
Show resolved
Hide resolved
| AwsCredentialsProvider defaultCredentialsProvider = clientConfiguration.option(AwsClientOption.CREDENTIALS_PROVIDER); | ||
| IdentityProvider<? extends AwsCredentialsIdentity> defaultCredentialsProvider = | ||
| clientConfiguration.option(AwsClientOption.CREDENTIALS_IDENTITY_PROVIDER); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually, similar to another comment, my thought on this being in the same aws-core module as AwsDefaultClientBuilder, makes me wonder if CREDENTIALS_IDENTITY_PROVIDER will still be set for older clients, that use the newer aws-core? Maybe there are other code paths or something I'm not thinking through.
To use the new credentialsIdentityProvider() instead.
...3/src/main/java/software/amazon/awssdk/services/s3/internal/crt/DefaultS3CrtAsyncClient.java
Show resolved
Hide resolved
.../auth/src/main/java/software/amazon/awssdk/auth/credentials/AwsCredentialsProviderChain.java
Outdated
Show resolved
Hide resolved
core/aws-core/src/main/java/software/amazon/awssdk/awscore/client/config/AwsClientOption.java
Outdated
Show resolved
Hide resolved
| // smithy codegen TODO: This could be removed when doing a minor version bump where we told customers we'll be breaking | ||
| // protected APIs. Postpone this to when we do Smithy code generator migration, where we'll likely have to start | ||
| // breaking a lot of protected things. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we put this somewhere that it doesn't mess up the javadoc for this field?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's in comments, so shouldn't affect javadoc. Either ways, if you think I should do something different here, lmk.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, I thought that since this comment separated the field from the javadoc that it would mess up the rendering.
core/auth/src/main/java/software/amazon/awssdk/auth/credentials/CredentialUtils.java
Show resolved
Hide resolved
|
SonarCloud Quality Gate failed. |








Motivation and Context
As part of SRA, earlier PR added the new interfaces. This PR updates existing code to accept and use the new interfaces.
Modifications
This PR updates existing interfaces like AwsClientBuilder and others where customers used to be able to provide AwsCredentialsProvider, to be able to provide the new interface -
IdentityProvider<? extends AwsCredentialsIdentity>.Pending:
Code generator changes for endpoint discovery case - SyncClientClass.I'm still working on adding tests.Testing
Updated existing tests. Added new tests.
Screenshots (if appropriate)
Types of changes
Checklist
mvn installsucceedsRan
./mvnw clean install -pl :auth,:aws-core,:s3,:polly,:rds -am -Pquicklocallyscripts/new-changescript and following the instructions. Commit the new file created by the script in.changes/next-releasewith your changes.License