Summary
Since the application runs in the eks environment, we have been guided to use a role when authenticating.
I need s3 file upload sample code using role.
When uploading file to s3
Use a role, not an access key.
Basic example
// Upload a local file to Amazon S3
S3AsyncClient s3Client = S3AsyncClient.crtCreate();
PutObjectResponse putObjectResponse =
s3Client.putObject(req -> req.bucket(BUCKET_NAME)
.key(downloadFileName),
AsyncRequestBody.fromFile(Paths.get(FILE_PATH)))
.join();
Motivation
You can do S3 FILE UPLOAD using a role.