Make sure your EC2 instance has the right permissions to upload to S3, like s3:PutObject and s3:GetObject. Double-check your S3 bucket’s region and access settings. You might also want to try turning on s3_use_acls: true if necessary. You can also test uploading directly with AWS CLI to rule out permission issues. And if you’re not using direct uploads, just leave enable_direct_s3_uploads: f as is. Should help fix the problem!
I was getting the same error message as the original poster here, with a similar configuration. I verified that I could get and put s3 objects using the AWS CLI from my EC2 instance even though Discourse was unable to do that.
I created a new IAM user with the same permissions policy as my EC2 instance role and used an access key instead of EC2 instance profile and now uploads work fine.
So in my case it wasn’t an issue of changing permissions, which makes me think that there may be a bug in instance profile authentication. Is there any way for me to get more information about why this was failing?