title: Node.js 303 Permanent Redirect when connecting to AWS-SDK
body: <p>Good afternoon,</p>
  
  <p>I'm trying to set up a connection to my aws product api, however I keep getting a 301 Permanent Redirect Error as follows:</p>
  
  <pre><code>{ [PermanentRedirect: The bucket you are attempting to access must be addressed using the specified endpoint. Please send all future requests to this endpoint.]
    message: 'The bucket you are attempting to access must be addressed using the specified endpoint. Please send all future requests to this endpoint.',
    code: 'PermanentRedirect',
    name: 'PermanentRedirect',
    statusCode: 301,
    retryable: false }
  </code></pre>
  
  <p>The code I am using to connect to the API is as follows:</p>
  
  <pre><code>var aws = require('aws-sdk');
  
  //Setting up the AWS API
  aws.config.update({
      accessKeyId: 'KEY',
      secretAccessKey: 'SECRET',
      region: 'eu-west-1'
  })
  
  var s3 = new aws.S3();
  
  s3.createBucket({Bucket: 'myBucket'}, function() {
      var params = {Bucket: 'myBucket', Key: 'myKey', Body: 'Hello!'};
      s3.putObject(params, function(err, data) {
          if (err)
              console.log(err)
          else
              console.log("Successfully uploaded data to myBucket/myKey");
      });
  });
  </code></pre>
  
  <p>If I try using different regions, like us-west-1 I just get the same error.</p>
  
  <p>What am I doing wrong?</p>
  
  <p>Thank you very much in advance! </p>