-
Notifications
You must be signed in to change notification settings - Fork 910
Missing dependency leads to opaque failover with DefaultCredentialsProvider #1915
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
Comments
I just spent the best part of this day on this exact same issue. The experience was rather puzzling. To debug I made the CLI tools print the IAM role it operates under and it showed up with the correct STS role. But my java app kept just insisting that it was under a different IAM role (it fell back to the default instance role silently). I would be good to throw an Exception when Or maybe better yet, just make sure the STS module is automatically added to the classpath by the modules that use it? Is there a specific reason to not add it to the classpath by default? Anyhow, just my two cents. |
@ascheja Apologies for the super long silence in here. This seems a reasonable ask, I'm marking as a feature request. You probably know this, but you can you set the client to specifically use the |
Unfortunately, it's difficult to infer intent just from the presence or absence of the environment variables or system properties; the situation described where the Web Identity provider failed so the chain moved on to the next one in the precedence list is the intended behavior of the chain. In this case, since the SDK is expected to use the S3Client s3 = S3Client.builder()
.region(Region.EU_WEST_1)
.credentialsProvider(WebIdentityTokenFileCredentialsProvider.create())
.build();
// will throw if WebIdentityTokenFileCredentialsProvider fails to initialize
s3.listBuckets(); |
It is true that this would fix the problem in a production environment, but for example when developing locally it's nice to have an automatic fallback to for example the cli profile. What about adding at least a higher level log message (maybe warn or even error?) in case of the |
Sure! I think this is reasonable. Would you like to submit a PR for this? |
Sure. |
|
Thanks! |
…f40572c41 Pull request: release <- staging/58af883d-9c24-43ff-98c9-edbf40572c41
Describe the issue
When using the
DefaultCredentialsProvider
with the intent to haveWebIdentityTokenFileCredentialsProvider
provide the credentials in a production kubernetes (EKS) environment without having thests
library on the classpath theDefaultCredentialsProvider
silently fails over to the nextCredentialsProvider
in the chain.The missing
sts
dependency leads to aClassNotFoundException
being rethrown as anIllegalStateException
(inWebIdentityCredentialsUtils.factory()
), but is immediately caught and assigned to a field. When theAwsCredentialsProviderChain
later callsresolveCredentials
on theWebIdentityTokenFileCredentialsProvider
that exception is rethrown and immediately being caught again byAwsCredentialsProviderChain
, moving to the nextCredentialsProvider
in the chain.In my case the next successful provider in the chain was the instance profile of the underlying worker node, discovered via ec2 metadata service, not having the required policies attached to call the API in question - in this case s3 - leading to a 403 Forbidden, putting myself on a wild goose chase trying to find out why my (perfectly well configured) kubernetes service account doesn't seem to have the required permission to call s3.
In my opinion the
ClassNotFoundException
should probably not be suppressed, as when reaching that point it's rather obvious (given that two environment variables or properties with the correct names exist) that it's the developer's intention to use web identity and the missing library being a mistake of said developer rather than a intended fallback to anotherCredentialProvider
.Steps to Reproduce
For simplicity's sake have a configured aws-cli profile (with no permissions to
GetObject
frommy-bucket
) lying in your home directory (~/.aws
).Run with s3 library (and transitional dependencies, but not
sts
) on classpath and both of these environment variables set to some string:AWS_WEB_IDENTITY_TOKEN_FILE
AWS_ROLE_ARN
Your Environment
The text was updated successfully, but these errors were encountered: