Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

A client error (400) occurred when calling the HeadObject operation: Bad Request Completed 1 part(s) with ... file(s) remaining

I'm trying to copy a file from a private s3-bucket via cli to my ec2 instance. The ec2 is in the same region as the bucket and has the following IAM role attached (AmazonS3FullAccess):

{
"Version": "2012-10-17",
"Statement": [
   {
     "Effect": "Allow",
     "Action": "s3:*",
     "Resource": "*"
   }
 ]
}

But the command:

aws s3 cp s3://[BUCKETNAME]/index.html /var/www/html/

fails with the error:

A client error (400) occurred when calling the HeadObject operation: Bad Request Completed 1 part(s) with ... file(s) remaining.

I already double checked the spelling of the bucket name...

like image 694
shootoke Avatar asked May 27 '16 13:05

shootoke


3 Answers

I added the --region option to the statement and everything is working now:

aws s3 cp s3:/[BUCKETNAME]/ . --recursive --region [REGION]
like image 116
shootoke Avatar answered Oct 16 '22 14:10

shootoke


This error also happens when your session has expired if using temporary security credentials with an assumed role. Not a forbidden or unknown id as you would expect.

like image 24
Nicholas Stevens Avatar answered Oct 16 '22 14:10

Nicholas Stevens


The --region parameter did not work for me.

I tried using --profile, and it worked all fine.

aws s3api head-bucket --bucket xxxx --profile dev-profile
like image 7
Niketh Sudhakaran Avatar answered Oct 16 '22 15:10

Niketh Sudhakaran