3

When login EC2 as ec2-user and run the following command:

aws s3 cp s3://mybucket/test/test.txt /home/ec2-user/

I got the following error:

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?

shifu.zheng
  • 691
  • 7
  • 16

2 Answers2

1

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.

shifu.zheng
  • 691
  • 7
  • 16
1

Sync should work.

aws s3 sync s3://s3-bucket-name/folder /home/ec2-user

Don't forget to set write access to the S3 bucket and set the IAM roles

Eric Leschinski
  • 146,994
  • 96
  • 417
  • 335
Ckappo
  • 607
  • 1
  • 9
  • 27