I'm using the awssdk v2: https://sdk.amazonaws.com/java/api/latest/
I want to put objects in S3 using a customer-managed KMS key for encryption at rest, I'm using sse-c to achieve this. However, it seems to always default to the AWS managed key as opposed to the customer managed one.
Following is my code:
PutObjectRequest putObjectRequest =
PutObjectRequest.builder()
.bucket(bucket)
.key(key)
.serverSideEncryption(ServerSideEncryption.AWS_KMS)
.ssekmsKeyId(this.s3KmsKeyId) // my key alias
.build();
s3Client.putObject(putObjectRequest, RequestBody.fromString(data)); // data = some string value
I am using PutObjectRequest to configure my request and S3Client to send it off to S3.
Since the keys are set to rotate, I cannot use an arn or the keyId
itself. I also can't seem to find an example of how this can be achieved using this sdk.