Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

"aws s3 ls" command throwing "InvalidRequest" error message. How to solve it?

After I run aws s3 ls command I get below error message:-

A client error (InvalidRequest) occurred when calling the ListBuckets operation: You are attempting to operate on a bucket in a region that requires Signature Version 4. You can fix this issue by explicitly providing the correct region location using the --region argument, the AWS_DEFAULT_REGION environment variable, or the region variable in the AWS CLI configuration file. You can get the bucket's location by running "aws s3api get-bucket-location --bucket BUCKET".

Below are more details and my findings that may help to answer the question:-

  • The command is being executed from an EC2 Instance running in ap-south-1 region.

  • This Amazon doc says that new region created after Jan 30 2014 only support Signature Version 4.

  • As suggested by error message I tried giving command aws --region ap-south-1 s3 ls but the this command also gives the same error message.

  • I have run yum update and the AWS CLI version is latest which is aws-cli/1.10.33 Python/2.7.10 Linux/4.4.11-23.53.amzn1.x86_64 botocore/1.4.23

  • The above aws s3 ls command works absolutely fine and lists the buckets if it is executed from an us-east-1 instance.

like image 962
Anuroop Avatar asked Jul 06 '16 09:07

Anuroop


People also ask

Why am I getting an access denied error from the Amazon S3 console when I try to modify a bucket policy?

The "403 Access Denied" error can occur due to the following reasons: Your AWS Identity and Access Management (IAM) user or role doesn't have permissions for both s3:GetBucketPolicy and s3:PutBucketPolicy. The bucket policy denies your IAM identity permission for s3:GetBucketPolicy and s3:PutBucketPolicy.

What is ls command in AWS?

The following ls command will recursively list objects in a bucket. Rather than showing PRE dirname/ in the output, all the content in a bucket will be listed in order: aws s3 ls s3://mybucket --recursive.

How do I reset my S3 bucket?

To empty an S3 bucketIn the Bucket name list, select the option next to the name of the bucket that you want to empty, and then choose Empty. On the Empty bucket page, confirm that you want to empty the bucket by entering the bucket name into the text field, and then choose Empty.


1 Answers

You need to update aws cli to latest version(v1.11.84 at the time of writing).

If yum update is not working then try following this Guide to install AWS CLI

The reason behind this error is, in newer regions AWS S3 doesn't support Lower Signature Version.

like image 88
Deepak Chaudhary Avatar answered Nov 15 '22 07:11

Deepak Chaudhary