Issue
When login EC2 as ec2-user and run the following command:
aws s3 cp s3://mybucket/test/test.txt /home/ec2-user/
fatal error: Unable to locate credentials
My bucket and my EC2 are created by the same account and in the same region. Why my EC2 can't access my S3 object?
Solution
I find that it is caused by missing role. In order to access S3 objects from EC2, I need to assign a role during the EC2 creation, and the role should has the access rights to S3.
Answered By - shifu.zheng Answer Checked By - Katrina (WPSolving Volunteer)