Skip to content

Commit 3198457

Browse files
committed
make BedrockAwsConnectionProperties#region empty by default (#3223)
Signed-off-by: Andrey Litvitski <[email protected]>
1 parent 0bbccf8 commit 3198457

File tree

6 files changed

+16
-7
lines changed

6 files changed

+16
-7
lines changed

auto-configurations/models/spring-ai-autoconfigure-model-bedrock-ai/src/main/java/org/springframework/ai/model/bedrock/autoconfigure/BedrockAwsConnectionProperties.java

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2023-2024 the original author or authors.
2+
* Copyright 2023-2025 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -24,6 +24,7 @@
2424
* Configuration properties for Bedrock AWS connection.
2525
*
2626
* @author Christian Tzolov
27+
* @author Andrey Litvitski
2728
* @since 0.8.0
2829
*/
2930
@ConfigurationProperties(BedrockAwsConnectionProperties.CONFIG_PREFIX)
@@ -32,9 +33,10 @@ public class BedrockAwsConnectionProperties {
3233
public static final String CONFIG_PREFIX = "spring.ai.bedrock.aws";
3334

3435
/**
35-
* AWS region to use. Defaults to us-east-1.
36+
* AWS region to use.
37+
* Otherwise the DefaultAwsRegionProviderChain will be used to resolve the region.
3638
*/
37-
private String region = "us-east-1";
39+
private String region;
3840

3941
/**
4042
* AWS access key.

auto-configurations/models/spring-ai-autoconfigure-model-bedrock-ai/src/test/java/org/springframework/ai/model/bedrock/cohere/autoconfigure/BedrockCohereModelConfigurationTests.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ public class BedrockCohereModelConfigurationTests {
3535

3636
private final ApplicationContextRunner contextRunner = new ApplicationContextRunner()
3737
.withConfiguration(AutoConfigurations.of(BedrockCohereEmbeddingAutoConfiguration.class))
38+
.withPropertyValues("spring.ai.bedrock.aws.region=us-east-1")
3839
.withBean(ObjectMapper.class, ObjectMapper::new);
3940

4041
@Test

auto-configurations/models/spring-ai-autoconfigure-model-bedrock-ai/src/test/java/org/springframework/ai/model/bedrock/converse/autoconfigure/BedrockConverseModelConfigurationTests.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
public class BedrockConverseModelConfigurationTests {
3434

3535
private final ApplicationContextRunner contextRunner = new ApplicationContextRunner()
36+
.withPropertyValues("spring.ai.bedrock.aws.region=us-east-1")
3637
.withConfiguration(AutoConfigurations.of(BedrockConverseProxyChatAutoConfiguration.class));
3738

3839
@Test

auto-configurations/models/spring-ai-autoconfigure-model-bedrock-ai/src/test/java/org/springframework/ai/model/bedrock/converse/autoconfigure/BedrockConverseProxyChatAutoConfigurationIT.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ public class BedrockConverseProxyChatAutoConfigurationIT {
4545
private final ApplicationContextRunner contextRunner = BedrockTestUtils.getContextRunner()
4646
.withPropertyValues(
4747
"spring.ai.bedrock.converse.chat.options.model=" + "anthropic.claude-3-5-sonnet-20240620-v1:0",
48-
"spring.ai.bedrock.converse.chat.options.temperature=0.5")
48+
"spring.ai.bedrock.converse.chat.options.temperature=0.5", "spring.ai.bedrock.aws.region=us-east-1")
4949
.withConfiguration(AutoConfigurations.of(BedrockConverseProxyChatAutoConfiguration.class));
5050

5151
@Test

auto-configurations/models/spring-ai-autoconfigure-model-bedrock-ai/src/test/java/org/springframework/ai/model/bedrock/converse/autoconfigure/BedrockConverseProxyChatPropertiesTests.java

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,8 @@ public void chatOptionsTest() {
4444

4545
"spring.ai.bedrock.converse.chat.options.temperature=0.55",
4646
"spring.ai.bedrock.converse.chat.options.top-p=0.56",
47-
"spring.ai.bedrock.converse.chat.options.top-k=100"
47+
"spring.ai.bedrock.converse.chat.options.top-k=100",
48+
"spring.ai.bedrock.aws.region=us-east-1"
4849
)
4950
// @formatter:on
5051
.withConfiguration(AutoConfigurations.of(BedrockConverseProxyChatAutoConfiguration.class))
@@ -67,18 +68,21 @@ public void chatCompletionDisabled() {
6768
// It is enabled by default
6869
new ApplicationContextRunner()
6970
.withConfiguration(AutoConfigurations.of(BedrockConverseProxyChatAutoConfiguration.class))
71+
.withPropertyValues("spring.ai.bedrock.aws.region=us-east-1")
7072
.run(context -> assertThat(context.getBeansOfType(BedrockConverseProxyChatProperties.class)).isNotEmpty());
7173

7274
// Explicitly enable the chat auto-configuration.
73-
new ApplicationContextRunner().withPropertyValues("spring.ai.model.chat=bedrock-converse")
75+
new ApplicationContextRunner()
76+
.withPropertyValues("spring.ai.model.chat=bedrock-converse", "spring.ai.bedrock.aws.region=us-east-1")
7477
.withConfiguration(AutoConfigurations.of(BedrockConverseProxyChatAutoConfiguration.class))
7578
.run(context -> {
7679
assertThat(context.getBeansOfType(BedrockConverseProxyChatProperties.class)).isNotEmpty();
7780
assertThat(context.getBeansOfType(BedrockProxyChatModel.class)).isNotEmpty();
7881
});
7982

8083
// Explicitly disable the chat auto-configuration.
81-
new ApplicationContextRunner().withPropertyValues("spring.ai.model.chat=none")
84+
new ApplicationContextRunner()
85+
.withPropertyValues("spring.ai.model.chat=none", "spring.ai.bedrock.aws.region=us-east-1")
8286
.withConfiguration(AutoConfigurations.of(BedrockConverseProxyChatAutoConfiguration.class))
8387
.run(context -> {
8488
assertThat(context.getBeansOfType(BedrockConverseProxyChatProperties.class)).isEmpty();

auto-configurations/models/spring-ai-autoconfigure-model-bedrock-ai/src/test/java/org/springframework/ai/model/bedrock/titan/autoconfigure/BedrockTitanModelConfigurationTests.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ public class BedrockTitanModelConfigurationTests {
3535

3636
private final ApplicationContextRunner contextRunner = new ApplicationContextRunner()
3737
.withConfiguration(AutoConfigurations.of(BedrockTitanEmbeddingAutoConfiguration.class))
38+
.withPropertyValues("spring.ai.bedrock.aws.region=us-east-1")
3839
.withBean(ObjectMapper.class, ObjectMapper::new);
3940

4041
@Test

0 commit comments

Comments
 (0)