Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Amazon S3 sync to local machine failed

I'm new to AWS and I'm trying to download a bunch of files from my S3 bucket to my local machine using aws s3 sync as described in http://docs.aws.amazon.com/cli/latest/reference/s3/sync.html. I used the following command:

aws s3 sync s3://outputbucket/files/ .

I got the following error: A client error (AccessDenied) occurred when calling the ListObjects operation: Access Denied Completed 1 part(s) with ... file(s) remaining

Even though I have configured my access key ID & secret access key as described in http://docs.aws.amazon.com/cli/latest/userguide/cli-chap-getting-set-up.html

Where might the problem be?

like image 228
troll Avatar asked Mar 08 '15 11:03

troll


People also ask

How do I transfer aws S3 bucket to localhost?

You can use cp to copy the files from an s3 bucket to your local system. Use the following command: $ aws s3 cp s3://bucket/folder/file.txt . To know more about AWS S3 and its features in detail check this out!

Does S3 sync copy locally?

The s3 sync command copies the objects from the local folder to the destination bucket, if: the size of the objects differs. the last modified time of the source is newer than the last modified time of the destination. the s3 object does not exist under the specified prefix in the destination bucket.

Why am I getting an access denied error for ListObjectsV2 when I run the sync command on my Amazon S3 bucket?

Verify that you have the permission for s3:ListBucket on the Amazon S3 buckets that you're copying objects to or from. You must have this permission to perform ListObjectsV2 actions. Note: s3:ListBucket is the name of the permission that allows a user to list the objects in a bucket.

How do I resolve access denied errors when uploading files to S3 with KMS default encryption?

To solve the access denied error, click Edit in the upper-right corner of the Default encryption area, and change the AWS KMS key to "Choose from your AWS KMS keys" or "Enter AWS KMS key ARN", or change the server-side encryption type to "AWS S3 Managed Key (SSE-S3).


2 Answers

Assuming that you are an Administrator and/or you have set your credentials properly, it is possible that you are using an old AWS CLI.

I encountered this while using the packaged AWS CLI with Ubuntu 14.04.

The solution that worked for me is to remove the AWS CLI prepackaged with Ubuntu, and download it from python-pip instead:

sudo apt-get remove awscli
sudo apt-get install python-pip
sudo pip install awscli

Many thanks to this link: https://forums.aws.amazon.com/thread.jspa?threadID=173124

like image 136
Ardee Aram Avatar answered Sep 17 '22 22:09

Ardee Aram


To perform a file sync, two sets of permissions are required:

  • ListObjects to obtain a list of files to copy
  • GetObjects to access the objects

If you are using your "root" user that comes with your AWS account, you will automatically have these permissions.

If you are using a user created within Identity and Access Management (IAM), you will need to assign these permissions to the User. The easiest way is to assign the AmazonS3FullAccess policy, which gives access to all S3 functions.

like image 33
John Rotenstein Avatar answered Sep 17 '22 22:09

John Rotenstein