-
Notifications
You must be signed in to change notification settings - Fork 247
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
set credentials_provider not working #973
Comments
And this is the code from v0.35, which works properly. /// Sets the credentials provider for this service
pub fn credentials_provider(mut self, credentials_provider: impl ::aws_credential_types::provider::ProvideCredentials + 'static) -> Self {
self.set_credentials_provider(::std::option::Option::Some(
::aws_credential_types::provider::SharedCredentialsProvider::new(credentials_provider),
));
self
}
/// Sets the credentials provider for this service
pub fn set_credentials_provider(
&mut self,
credentials_provider: ::std::option::Option<::aws_credential_types::provider::SharedCredentialsProvider>,
) -> &mut Self {
self.config.store_or_unset(credentials_provider);
self
} |
Maybe related: smithy-lang/smithy-rs#3156 |
Hi @MrCroxx, thank you for reporting this! You are right about There are two things to note:
We use test credentials throughout our tests (example). You shared with us the method definitions above, but could you also share a code snippet (or pseudo code) that runs into the problem because I do agree that the API |
@ysaito1001 Hi, thanks for your reply.
Here is the code. It works well with 0.35 and before, which is the last version that credentials provider is set with
I don't totally get that. I found after |
I think you're asking how our code internally knows how to provide credentials with credentials passed by a customer? The internals of the client (in this case You can turn on
to confirm that (you can look for words in tracing output "resolved identity"). I assume the highlighted code no longer works with a version of |
I think we could make this accessor work properly—I agree the current behavior is pretty confusing. Setting the credentials provider should definitely be working though—so let us know the behavior. you're seeing |
@rcoh @ysaito1001 Hi, thanks for helping. Here is my log. You can see that from the trace log, the shared credentials provider uses the hard-coded static access key id "hummockadmin", but when the client accessing S3, it uses the credentials loaded from my config file (I've hidden it with |
FYI: The behavior with 0.35:
|
Quick question: How resolver know which identity to use if there are identities from env and hard-coded? Code in 0.35 use |
Okay, I finally made my code work again. In short, the not-behaving code looks like the following: aws_sdk_s3::config::Builder::from(
&aws_config::ConfigLoader::default()
.load()
.await,
)
.credentials_provider(Credentials::from_keys(
access_key_id,
secret_access_key,
None,
))
.build(); The builder is loaded from the default config loader, then its credentials provider is modified. (Internally, it pushes an identity resolver to its runtime components, not overrides it.) I modified the code like this and it works: aws_sdk_s3::config::Builder::from(
&aws_config::ConfigLoader::default()
.credentials_provider(Credentials::from_keys(
access_key_id,
secret_access_key,
None,
))
.load()
.await,
)
.build(); The credentials provider is set before the default config is loaded, if the field is set before loading, the property will not be loaded again. So there is only one credentials provider in the runtime components and will be used when accessing s3. |
But still, is the behavior as expected? At least, the comments on |
upstream issue: awslabs/aws-sdk-rust#973 Signed-off-by: MrCroxx <[email protected]>
Thanks for sharing with us the working version! In general, we recommend configuring things through |
Ticket auto-closed in error. The fix hasn't been released yet. |
This fix for this went out in the December 5, 2023 release. |
|
Describe the bug
When building config for client,
Builder::credentials_provider
does the following things:credientials_provider
is set byruntime_components
. But after build,Config::credientials_provider
does this:It loads credentials provider from its
config
field notruntime_components
. So it is alwaysNone
. And I cannot make my hard-coded credentials for minio test env work.Expected Behavior
Builder::credentials_provider
set the right field orConfig::credentials_provider
get from the right field.Current Behavior
Builder::credentials_provider
setruntime_components
butConfig::credentials_provider
get fromconfig
.Reproduction Steps
Set any credentials provider and get, got
None
.Possible Solution
As mentioned.
Additional Information/Context
No response
Version
Environment details (OS name and version, etc.)
Linux / Mac
Logs
No response
The text was updated successfully, but these errors were encountered: