-
Notifications
You must be signed in to change notification settings - Fork 196
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
credentials_cache method takes CredentialsCache, needs to take SharedCredentialsCache #2945
Comments
I don't think that let config = Config::builder()
.credentials_cache(CredentialsCache::lazy_builder()
// set some things ...
.build()
)
.credentials_provider(my_provider)
.build(); The Config builder will combine the two for you. |
I see. I think previously we were able to share a credential cache across multiple different clients, whereas with this design I think that isn't possible without some legwork to create a credential provider from a credentials cache? |
Oh, sorry, I think I answered incorrectly the first time. I didn't realize the API was different between If you can, use |
Hm, actually SdkConfig has the same problem it seems? https://docs.rs/aws-types/latest/aws_types/sdk_config/struct.Builder.html#method.credentials_cache takes a CredentialsCache. Do you mean that we can create it via https://docs.rs/aws-config/latest/aws_config/fn.from_env.html which under the hood does the right thing? |
That |
That doesn't seem to be true looking at the code? SdkConfig::build doesn't do anything with the cache (src), and SdkConfig::set_credentials_cache doesn't either (src). The service-specific config does that: https://docs.rs/aws-sdk-ec2/latest/src/aws_sdk_ec2/config.rs.html#786-798, but that's not super helpful for my case where I'm looking to share a set of cached credentials across multiple clients with distinct configurations, including across multiple services. I suppose this is enough that within one service I can make this work (by keeping around a built Config to go back from via to_builder)... |
You're correct—There is currently somewhere between a bug and an anti feature that although the provider is shared, each service ends up with its own cache. This isn't a huge issue for long-lived processes but it is quite annoying for things like a CLI where it's going to re-hit the provider for each service. If these don't need to be long lived credentials, one |
OK, thanks for confirming. I'll look into the workaround, it might be feasible for us to use it for the current use case. Can you say more about anti-feature though? What are the benefits to distinct caches per service for the credentials? Is there a design doc or similar on that? |
There aren't really (other than the somewhat esoteric use case of getting different caching strategies for different services)—it was an emergent/unexpected side-effect of a redesign that attempted to make it harder to misuse credentials providers, ironically. It's on our list to fix. |
this was resolved by the orchestrator however, #3427 does still exist and needs to be fixed. |
I think it's preferred to pass a credentials cache instead of a credentials provider. Right now, that's not really possible, because creating a credentials cache with credentials involves calling CredentialsCache::create_cache. This returns SharedCredentialsCache.
However, client builders take a CredentialsCache (not Shared) -- e.g., ec2, which means there doesn't seem to be a way to pass the cache-with-credentials in.
The text was updated successfully, but these errors were encountered: