Skip to content

Commit

Permalink
Set HTTP provicer for S3Client
Browse files Browse the repository at this point in the history
  • Loading branch information
inigo-cobian committed Jan 30, 2025
1 parent 91add51 commit 7d51d03
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
12 changes: 12 additions & 0 deletions klab.engine/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -960,6 +960,18 @@
<version>${junit5.version}</version>
<scope>test</scope>
</dependency>
<!--- AWS dependencies-->
<dependency>
<artifactId>apache-client</artifactId>
<groupId>software.amazon.awssdk</groupId>
<version>${aws.version}</version>
<exclusions>
<exclusion>
<groupId>commons-logging</groupId>
<artifactId>commons-logging</artifactId>
</exclusion>
</exclusions>
</dependency>

</dependencies>
</project>
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import java.util.stream.Collectors;

import software.amazon.awssdk.auth.credentials.AnonymousCredentialsProvider;
import software.amazon.awssdk.http.apache.ApacheHttpClient;
import software.amazon.awssdk.regions.Region;
import software.amazon.awssdk.services.s3.S3Client;
import software.amazon.awssdk.services.s3.model.GetBucketLocationRequest;
Expand All @@ -19,6 +20,7 @@ public static Region resolveBucketRegion(String bucketName, String objectKey) {

// Step 1: Attempt to dynamically resolve the bucket's region
try (S3Client s3 = S3Client.builder()
.httpClientBuilder(ApacheHttpClient.builder())
.region(defaultRegion) // Use the default region
.credentialsProvider(AnonymousCredentialsProvider.create()) // Anonymous credentials
.build()) {
Expand Down

0 comments on commit 7d51d03

Please sign in to comment.