It looks like you solved it in the comments, but I was burned on this and want to leave a clearer answer to future readers. To be very clear, the problem here has nothing to do with files in S3. This error message has nothing to do with the file on your hard drive or the file that you are trying to push / pull from S3. The problem is that you initialize S3 with something like:
AmazonS3 s3Client = new AmazonS3Client(new ProfileCredentialsProvider());
When you do this, it looks in ~ / .aws / credentials for a list of profiles. This may work fine on your computer, but will not work anywhere when you access AWS through the IAM role (e.g. Lambda, Docker, EC2, etc.). Bugfix: initialize AmazonS3Client as follows:
AmazonS3 s3Client = new AmazonS3Client();
If you use code that requires a credential provider, you can also:
AmazonS3 s3Client = new AmazonS3Client(DefaultAWSCredentialsProviderChain.getInstance());
Hope this helps the next person. In my case, I used DynamoDB and SQS, but I had the same error. I initially ignored this question because I thought your problem with S3 was confused. Wrist slap.
Ryan shillington
source share