New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

region issue using signature v4 #986

Closed
ghost opened this Issue May 4, 2016 · 3 comments

Comments

Projects
None yet
1 participant
@ghost
Copy link

ghost commented May 4, 2016

I'm using this sdk with nodejs and I'm having an issue with the region of the signature.

My code is like this:

aws.config.accessKeyId = this.s3config.auth.id;
aws.config.secretAccessKey = this.s3config.auth.key;
aws.config.region = this.s3config.awsRegion;

var s3 = new aws.S3({
  region: this.s3config.awsRegion,
  signatureVersion: 'v4'
});

s3.getObject({Bucket: 'abcdef', Key: 'abcdef.json'}, function(err, data) {
    console.log(err);
});

And this is the err:

{ [AuthorizationHeaderMalformed: The authorization header is malformed; the region 'us-east-1' is wrong; expecting 'eu-central-1']
  message: 'The authorization header is malformed; the region \'us-east-1\' is wrong; expecting \'eu-central-1\'',
  code: 'AuthorizationHeaderMalformed',
  time: Wed May 04 2016 23:26:09 GMT+0200 (CEST),
  statusCode: 400,
  retryable: false,
  retryDelay: 30 }

How I can specify the region for the signature?

@LiuJoyceC LiuJoyceC self-assigned this May 4, 2016

@LiuJoyceC

This comment has been minimized.

Copy link
Contributor

LiuJoyceC commented May 4, 2016

Hi @xGabryMC
It looks like you are configuring your s3 client to 'us-east-1'. Is the value of this.s3config.awsRegion equal to 'us-east-1'?
You will need to pass in 'eu-central-1' to either aws.config.region or to region when you create the s3 instance.
So either do:

aws.config.region = 'eu-central-1';
var s3 = new aws.S3({
  // do not override the region
  signatureVersion: 'v4' // this is actually not necessary because for 'eu-central-1' the default is 'v4'
});

or do:

var s3 = new aws.S3({
  region: 'eu-central-1',
  signatureVersion: 'v4' // this is actually not necessary because for 'eu-central-1' the default is 'v4'
});

Let me know if that helps!

@LiuJoyceC

This comment has been minimized.

Copy link
Contributor

LiuJoyceC commented May 4, 2016

@xGabryMC
What version of the AWS SDK are you using? If it's version 2.2.13 or later, and as long as you're not specifying maxRetries of 0, then the SDK should be automatically correcting the region for you when you get an AuthorizationHeaderMalformed error that contains information about your bucket's region.

@ghost

This comment has been minimized.

Copy link

ghost commented May 5, 2016

I've seen the version from the package.json in /node_modules/aws-sdk and it is the 2.0.31.
Now I'm using the version 2.3.8 and all seems to work just fine.

I can close the issue,
Regards.

@ghost ghost closed this May 5, 2016

This issue was closed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment