feat(bedrock): support AWS credentials files#761
Conversation
apcha-oai
left a comment
There was a problem hiding this comment.
[codex] Two non-blocking lifecycle comments from the requested review.
| CompletableFuture.supplyAsync { authenticate(request) } | ||
|
|
||
| override fun close() { | ||
| (credentialsProvider as? AutoCloseable)?.close() |
There was a problem hiding this comment.
[codex] Non-blocking: what ownership semantics do we want for a caller-supplied AwsCredentialsProvider? This closes any provider implementing AutoCloseable, including one shared with another client, but awsCredentialsProvider(...) does not currently say that ownership transfers. Could we either close only providers created internally, or explicitly document that the Bedrock client takes ownership and closes the supplied provider?
| } | ||
|
|
||
| override fun close() { | ||
| authenticator.close() |
There was a problem hiding this comment.
[codex] Non-blocking hardening: if authenticator.close() throws, delegate.close() is skipped and the underlying transport resources may remain open. Could we ensure the delegate is closed in a finally block (preserving/suppressing both exceptions as appropriate)?
apcha-oai
left a comment
There was a problem hiding this comment.
[codex] Adding the missed P1 inline comment.
| normalizedRegion | ||
| ?: normalizeEnvironment(getenv("AWS_REGION")) | ||
| ?: normalizeEnvironment(getenv("AWS_DEFAULT_REGION")) | ||
| ?: regionProvider()?.id() |
There was a problem hiding this comment.
[codex] [P2] Could we resolve the default AWS region lazily? With an explicit baseUrl(...) plus apiKey/bedrockTokenProvider, or baseUrl(...) plus skipAuth(true), this still invokes DefaultAwsRegionProviderChain. That chain may consult shared config and EC2 metadata even though these modes do not need a SigV4 region, adding unexpected I/O or startup delay. I’d only invoke it when deriving the regional default endpoint or constructing the SigV4 authenticator, and add a test with a throwing regionProvider for the explicit-base-URL bearer/skip-auth cases.
Fixes SDK-80
Linear: SDK-80 — Support for aws credentials file - Java
Summary
openai-java-bedrockartifact for OpenAI-compatible APIs on Amazon BedrockWhy
Java users currently need to load AWS credentials themselves before using Bedrock's OpenAI-compatible endpoint. This adds first-class support for the standard AWS credentials workflow, including
~/.aws/credentials, named profiles, workload credentials, and runtime identities, while keeping AWS dependencies isolated to an optional module.Implementation notes
Validation