Skip to content
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

Allow BedrockProxyChatModel to use AWS default region configuration #2146

Open
yargna opened this issue Jan 29, 2025 · 0 comments
Open

Allow BedrockProxyChatModel to use AWS default region configuration #2146

yargna opened this issue Jan 29, 2025 · 0 comments

Comments

@yargna
Copy link

yargna commented Jan 29, 2025

Currently, BedrockProxyChatModel in spring-ai-bedrock-converse does not automatically pick up the AWS region from standard AWS configuration mechanisms, such as:

  • Environment variable (AWS_REGION)
  • AWS shared config file (~/.aws/config)
  • System properties (-Daws.region=us-west-2)
  • Instance metadata service (IMDS) (EC2/ECS)

Instead, it defaults to us-east-1, unless explicitly overridden via .region(Region.of(...)).

Please update AWS region retrieval in BedrockProxyChatModel to ensure consistency with other AWS SDK clients. This is especially important for services that are already running in AWS environment.

Expected Behavior

The following code should properly pick up the region from available sources similar to other AWS clients:

@Bean
public BedrockProxyChatModel bedrockChatModel() {
    return BedrockProxyChatModel.builder().build();
}

Current Behavior

BedrockProxyChatModel.builder().build() overrides the region with us-east-1.

Context

I want to integrate AWS Bedrock seamlessly, just like other AWS services, with minimal configuration. Other AWS SDK clients pick up the configuration automatically from the environment, which is crucial when running in AWS environments where overriding variables is discouraged. This ensures better interoperability and allows smooth transitions between regions or accounts without requiring manual adjustments. The expectation is that services should work out of the box with the existing AWS configuration, improving ease of deployment and consistency across different environments.

Currently I have to emulate it like this:

@Bean
public BedrockProxyChatModel bedrockChatModel() {
    var defaultAwsRegionProviderChain = DefaultAwsRegionProviderChain.builder().build();

    return BedrockProxyChatModel
            .builder()
            .withRegion(defaultAwsRegionProviderChain.getRegion())
            .build();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant