user1709062
user1709062

Reputation: 223

The authorization header is malformed; the region 'us-east-1' is wrong; expecting 'eu-central-1'

using Node.JS with the following config file

{ "accessKeyId" :"XXX", "secretAccessKey" :"XXXX", "region": "eu-central-1", "signatureVersion": "v4" }

I still receive this error message as if the aws sdk tries to access a us-east-1 region .

Any idea ?

Upvotes: 18

Views: 50518

Answers (4)

Kartikeya Singh
Kartikeya Singh

Reputation: 27

try to create that resource manually in aws , if not able to create , change the resource name in terraform script with something unique

Upvotes: 0

mirhossein
mirhossein

Reputation: 737

I think the cause would be revealed if you enable the logs

import boto3
boto3.set_stream_logger('botocore', level='DEBUG')

In my case, I didn't set region name and received that error, but boto3 retires automatically after that with the correct region name

Upvotes: 0

Ori Shemla
Ori Shemla

Reputation: 51

I ran into the same issue on 2023.

This tutorial helped me. It basically says that the bucket name need to be unique accross the whole region with all of the AWS accounts there are, so by changing my bucket name the issue was solved.

https://spacelift.io/blog/terraform-aws-provider

Upvotes: 5

mon
mon

Reputation: 22234

According to AWS, there are three situations this can happen.

  1. When you are creating a bucket with a name that this already being used as a bucket name in your AWS account or in any other AWS account (Please note that S3 bucket names are globally unique).

  2. When you are doing an operation on your S3 bucket and you have set the Region variable (either when configuring the SDK or while using environment variables etc) to a region other than the one in which the bucket is actually present.

  3. You have recently deleted a S3 bucket in a particular region (say us-east-1) and you are trying to create a bucket (with the same name as the the bucket that was deleted) in another region right after deleting the bucket.

For point 3, give it up to two days and retry.

if a bucket which is present in a certain region say (us-east-1) is deleted, you can always create a bucket with the same name in another region. There is no such restriction in S3 that states you cannot do this. However, you will be able to do this only after you allow some time after deleting the bucket. This is because S3 buckets follow the Eventual Consistency model in the case of DELETE operation.

It means that after you delete a bucket, it takes a few hours, generally up-to 24 to 48 hours for the DELETE operation to be replicated across all our data centres. Once this change has propagated you can go ahead and create the bucket again in the desired region.

Upvotes: 43

Related Questions