viq
viq

Reputation: 417

Access denied with new Amazon S3 Java SDK V2

i'm migrating AWS SDK 1 to 2 for S3, and getting Access Denied exception for every operation in my region us-east-1. That didn't happen when i used sdk1. I've tried to troubleshoot this and find out that S3 client was used with

clientConfiguration.setSignerOverride("S3SignerType");

Which i didn't find with SDK version 2.

Any advices would be helpful! Thank you.

Upvotes: 0

Views: 682

Answers (1)

smac2020
smac2020

Reputation: 10734

To work with Overrides when using the Amazon S3 Java API V2, refer to the Javadocs here:

https://sdk.amazonaws.com/java/api/latest/software/amazon/awssdk/core/client/builder/SdkClientBuilder.html#endpointOverride-java.net.URI-

See:

  • endpointOverride

  • endpointOverride(URI endpointOverride)

You can create a URI object and pass that when you create the Service client

   URI myURI = new URI("<endpoint URL>");
   Region region = Region.US_EAST_1;
   S3Client s3 = S3Client.builder()
                .region(region)
                .endpointOverride(myURI)
                .build();

Upvotes: 1

Related Questions