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();
}

Comment From: markpollack

@maschnetwork

Comment From: markpollack

Duplicate of https://github.com/spring-projects/spring-ai/issues/823

Comment From: tzolov

@yargna, perhaps we need to change the spring.ai.bedrock.aws.region to be empty by default, which will bring the default region.

As a workaround you can set spring.ai.bedrock.aws.region= to achieve the same?

Comment From: yargna

@tzolov @ashakirin Thanks a lot for fixing it! I can confirm that with 1.0.0 I didn't have to use the above workaround anymore, it just worked out of the box. I can also see the code changes, and they look good

Also, I can confirm that I didn't set spring.ai.bedrock.aws.region property at all in the past.