title: Trying to connect to a S3 Bucket with Hadoop FileSystem but jumps an error saying the bucket is in this region
body: <p>I'm trying to use the Hadoop API to connect to an Amazon S3 bucket. I'm using the org.apache.hadoop.fs.FileSystem class in order to connect to the bucket and create a new file.</p>
  
  <pre><code>import org.apache.hadoop.conf.Configuration;
  import org.apache.hadoop.fs.*;
  import java.net.URI;
  public class FileMover {
  
  public static void main(String [] args) {
  
      URI s3uri=URI.create(“s3a://mybucket”);
      Configuration conf = new Configuration();
      FileSystem s3fs=FileSystem.get(s3uri,conf);
      s3fs.create(new Path(“s3a://mybucket/MyFile”));
   }
  
  }
  </code></pre>
  
  <p>But this generates the following error </p>
  
  <pre><code>org.apache.hadoop.fs.s3a.AWSS3IOException: getFileStatus on s3a://mybucket/Jesus/test: com.amazonaws.services.s3.model.AmazonS3Exception: 
  The bucket is in this region: eu-west-3. 
  Please use this region to retry the request (Service: Amazon S3; Status Code: 301; Error Code: 301 Moved Permanently; Request ID: 3D3A4C0CE06CCF8B), S3 Extended Request ID: rDKHmonuOeVi2PhwTZ3ByLD3LGBZ+kbTvqwZ8/hfUAs8y9ei88HosVSuOqdGJa8VtjvOXZ8/DiE=: 
  The bucket is in this region: eu-west-3. Please use this region to retry the request (Service: Amazon S3; Status Code: 301; Error Code: 301 Moved Permanently; Request ID: 3D3A4C0CE06CCF8B)
  </code></pre>
  
  <p>This is the configuration i set in the core-site.xml</p>
  
  <pre><code>&lt;configuration&gt;
    &lt;property&gt;
      &lt;name&gt;fs.defaultFS&lt;/name&gt;
      &lt;value&gt;hdfs://quickstart.cloudera:8020&lt;/value&gt;
    &lt;/property&gt;
  
  
  
    &lt;property&gt;
      &lt;name&gt;fs.s3a.access.key&lt;/name&gt;
      &lt;value&gt;XXXXXXXXXXXX&lt;/value&gt;
    &lt;/property&gt;
  
    &lt;property&gt;
      &lt;name&gt;fs.s3a.secret.key&lt;/name&gt;
      &lt;value&gt;XXXXXXXXXXXX&lt;/value&gt;
    &lt;/property&gt;
  
  
    &lt;!-- OOZIE proxy user setting --&gt;
    &lt;property&gt;
      &lt;name&gt;hadoop.proxyuser.oozie.hosts&lt;/name&gt;
      &lt;value&gt;*&lt;/value&gt;
    &lt;/property&gt;
    &lt;property&gt;
      &lt;name&gt;hadoop.proxyuser.oozie.groups&lt;/name&gt;
      &lt;value&gt;*&lt;/value&gt;
    &lt;/property&gt;
  
    &lt;!-- HTTPFS proxy user setting --&gt;
    &lt;property&gt;
      &lt;name&gt;hadoop.proxyuser.httpfs.hosts&lt;/name&gt;
      &lt;value&gt;*&lt;/value&gt;
    &lt;/property&gt;
    &lt;property&gt;
      &lt;name&gt;hadoop.proxyuser.httpfs.groups&lt;/name&gt;
      &lt;value&gt;*&lt;/value&gt;
    &lt;/property&gt;
  
    &lt;!-- Llama proxy user setting --&gt;
    &lt;property&gt;
      &lt;name&gt;hadoop.proxyuser.llama.hosts&lt;/name&gt;
      &lt;value&gt;*&lt;/value&gt;
    &lt;/property&gt;
    &lt;property&gt;
      &lt;name&gt;hadoop.proxyuser.llama.groups&lt;/name&gt;
      &lt;value&gt;*&lt;/value&gt;
    &lt;/property&gt;
  
    &lt;!-- Hue proxy user setting --&gt;
    &lt;property&gt;
      &lt;name&gt;hadoop.proxyuser.hue.hosts&lt;/name&gt;
      &lt;value&gt;*&lt;/value&gt;
    &lt;/property&gt;
    &lt;property&gt;
      &lt;name&gt;hadoop.proxyuser.hue.groups&lt;/name&gt;
      &lt;value&gt;*&lt;/value&gt;
    &lt;/property&gt;
  
  &lt;/configuration&gt;
  </code></pre>
  
  <p>I tried to set the endpoint in the core-site.xml to the one requested in the error but it doesn't work.</p>