Example of how to connect AWS S3 using the access key and secret key or the IAM role. Sample code to upload, download, list and delete objects in S3 bucket using AWS Java SDK 2.
Refer complete article at: https://www.bytestree.com/cloud/aws/aws-s3-java-sdk-v2/