I have to migrate from AmazonS3EncryptionClient to AmazonS3EncryptionClientV2, therefore I was following these instructions: https://docs.aws.amazon.com/sdk-for-java/v1/developer-guide/s3-encryption-migration.html, but I'm always running into the same error, even though the region is set: "Unable to find a region via the region provider chain. Must provide an explicit region in the builder or setup environment to supply a region."
AmazonS3 s3Encryption = AmazonS3EncryptionClientV2.encryptionBuilder()
.withRegion(Regions.EU_CENTRAL_1)
.withCredentials(new AWSStaticCredentialsProvider(
new BasicAWSCredentials(AWS_S3_KEY, AWS_S3_SECRET)))
.withCryptoConfiguration(new CryptoConfigurationV2()
// The following setting allows the client to read V1 encrypted objects
.withCryptoMode(CryptoMode.AuthenticatedEncryption)
.withCryptoProvider(new BouncyCastleProvider()))
.withEncryptionMaterialsProvider(new StaticEncryptionMaterialsProvider(
new EncryptionMaterials(createKeyPair(AWS_S3_PRIVATE_KEY,
AWS_S3_PUBLIC_KEY))))
.build();
<dependency>
<groupId>com.amazonaws</groupId>
<artifactId>aws-java-sdk-s3</artifactId>
<version>1.11.908</version>
</dependency>
Has anyone of an idea? Because when I use another client like the AmazonS3ClientBuilder everything works fine.