S3AsyncClient client = S3AsyncClient.create();
CompletableFuture<PutObjectResponse> future = client.putObject(
PutObjectRequest.builder().bucket(BUCKET)
.key(fileName)
.build(),
AsyncRequestBody
.fromFile(fromFile.toPath()));
future.whenComplete((resp, err) -> {
try {
if (resp != null) {
System.out.println("my response: " + resp);
} else {
// Handle error
err.printStackTrace();
}
} finally {
// Lets the application shut down. Only close the client when
// you are completely done with it.
client.close();
}
});
future.join();
}
Hmm, this part is interesting:
InstanceProfileCredentialsProvider(): Interrupted waiting to refresh the value
I wonder if it helps at all to set up the credentials provider to get the IAM credentials asynchronously. Maybe try replacing the first line of your code with something like:
AwsCredentialsProvider awsCredentialsProvider = InstanceProfileCredentialsProvider.builder().asyncCredentialUpdateEnabled(Boolean.TRUE).build();
S3AsyncClient client = S3AsyncClient.builder().credentialsProvider(awsCredentialsProvider).build();
Other than that, I'm not too sure - haven't worked too much with Java + AWS/S3 recently.
Some debugging steps you can try: