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

Fix S3Presigner region resolution #937

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,8 @@ S3Template s3Template(S3Client s3Client, S3OutputStreamProvider s3OutputStreamPr
S3Presigner s3Presigner(S3Properties properties, AwsProperties awsProperties,
AwsCredentialsProvider credentialsProvider, AwsRegionProvider regionProvider) {
S3Presigner.Builder builder = S3Presigner.builder().serviceConfiguration(properties.toS3Configuration())
.credentialsProvider(credentialsProvider).region(regionProvider.getRegion());
.credentialsProvider(credentialsProvider)
.region(AwsClientBuilderConfigurer.resolveRegion(properties, regionProvider));

if (properties.getEndpoint() != null) {
builder.endpointOverride(properties.getEndpoint());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,22 @@ void setsCommonAwsPropertiesOnPresigner() {
assertThat(presigner.getRegion()).isEqualTo(Region.of("eu-west-1"));
});
}

@Test
void setsRegionFromProperties() {
contextRunner.withPropertyValues("spring.cloud.aws.s3.region:us-east-1").run(context -> {
ConfiguredAwsPresigner presigner = new ConfiguredAwsPresigner(context.getBean(S3Presigner.class));
assertThat(presigner.getRegion()).isEqualTo(Region.of("us-east-1"));
});
}

@Test
void setsRegionToDefault() {
contextRunner.run(context -> {
ConfiguredAwsPresigner presigner = new ConfiguredAwsPresigner(context.getBean(S3Presigner.class));
assertThat(presigner.getRegion()).isEqualTo(Region.of("eu-west-1"));
});
}
}

@Configuration(proxyBeanMethods = false)
Expand Down
Loading