UID2-4739: use DefaultCredentialsProvider for KMS client in JWTTokenProvider#406
UID2-4739: use DefaultCredentialsProvider for KMS client in JWTTokenProvider#406sophia-chen-ttd wants to merge 1 commit into
Conversation
…rovider Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
sophia-chen-ttd
left a comment
There was a problem hiding this comment.
The swap from WebIdentityTokenFileCredentialsProvider to DefaultCredentialsProvider is correct and aligns with AWS SDK v2 best practice. The change broadens credential chain support (IRSA, EKS Pod Identity, instance profiles, env vars, etc.) without affecting the static-credentials fast-path. No functional regressions are expected, but the expanded credential chain introduces some operational subtleties worth noting.
| } | ||
| } else { | ||
| WebIdentityTokenFileCredentialsProvider credentialsProvider = WebIdentityTokenFileCredentialsProvider.create(); | ||
| DefaultCredentialsProvider credentialsProvider = DefaultCredentialsProvider.create(); |
There was a problem hiding this comment.
Claude Review: DefaultCredentialsProvider.create() walks a multi-step chain on first call: env vars → system properties → web-identity token file → EKS Pod Identity → EC2 IMDS → ECS credentials. In a cold-start or misconfigured environment this can add latency (IMDS timeouts are 1 s by default, retried twice) before failing. Consider whether the KMS client construction path is latency-sensitive at startup; if so, add an inline comment naming the expected credential source so operators know what to look for when diagnosing slow starts.
| } | ||
| } else { | ||
| WebIdentityTokenFileCredentialsProvider credentialsProvider = WebIdentityTokenFileCredentialsProvider.create(); | ||
| DefaultCredentialsProvider credentialsProvider = DefaultCredentialsProvider.create(); |
There was a problem hiding this comment.
Claude Review: With WebIdentityTokenFileCredentialsProvider the IAM principal was always the IRSA service-account role — scope was predictable. With DefaultCredentialsProvider the resolved principal depends on the runtime environment (personal IAM user on a dev laptop, shared CI role, etc.). Confirm KMS key policies are updated to allow the new EKS Pod Identity role ARN, and that local/CI environments mock KMS or use a separate key.
| } | ||
| } else { | ||
| WebIdentityTokenFileCredentialsProvider credentialsProvider = WebIdentityTokenFileCredentialsProvider.create(); | ||
| DefaultCredentialsProvider credentialsProvider = DefaultCredentialsProvider.create(); |
There was a problem hiding this comment.
Claude Review: No unit tests appear to cover the non-static-credentials branch of getKmsClient (the else-branch changed here). Consider adding a test that passes a JsonObject without kmsAccessKey/kmsSecretKey and asserts the builder receives a DefaultCredentialsProvider, so a future regression would be caught by CI.
Summary
JWTTokenProviderexplicitly constructsWebIdentityTokenFileCredentialsProviderfor KMS access, which ties it to OIDC/IRSA. Switching toDefaultCredentialsProvidermakes it compatible with EKS Pod Identity, instance profiles, and any future credential mechanism — matching the standard AWS SDK v2 best practice of letting the credential chain resolve at runtime.WebIdentityTokenFileCredentialsProvider.create()withDefaultCredentialsProvider.create()in the non-static-credentials branch ofgetKmsClientCompanion fix to
CloudStorageS3.java(UID2-4739).Test plan
🤖 Generated with Claude Code