I'm facing a problem of how to initialize the AWS S3 Asynchronous Encryption (SDK V3) using Java.
The documentation was not that clear for me. This is the code from the documentation
class v3EnableAsyncClientExample {
public static void main(String[] args) {
S3AsyncClient v3Client = S3AsyncEncryptionClient.builder()
.kmsKeyId(kmsKeyId)
.build();
}
}
And this is my code
public void encrypt(){
var keyRing = "myKmsArn" // my ARN KMS Key from AWS KMS
var s3Client = S3AsyncEncryptionClient.builder()
.kmsKeyId(keyRing)
.build();
}
But when I run the function, I got this error
software.amazon.awssdk.core.exception.SdkClientException: Unable to load region from any of the providers in the chain software.amazon.awssdk.regions.providers.DefaultAwsRegionProviderChain@2bf641a: [software.amazon.awssdk.regions.providers.SystemSettingsRegionProvider@4d4a2fba: Unable to load region from system settings. Region must be specified either via environment variable (AWS_REGION) or system property (aws.region)., software.amazon.awssdk.regions.providers.AwsProfileRegionProvider@2ebabcb7: No region provided in profile: default, software.amazon.awssdk.regions.providers.InstanceProfileRegionProvider@4442e7e0: Unable to contact EC2 metadata service.]
I already create a KMS for encrypt and decrypt. But I still got that error.

Thank you, I need help
You need to setup your environment to tell the SDK which region to interact with. You can accomplish this a few different ways, the simplest is to add this line to the top of your main method:
and replace the region with the one you're operating in.
Another, more permanent, option is to update your
~/.aws/configfile to specific a default region. Example: