title: AWS CLI: aws s3 presign does not work for ap-east-1 (Hong Kong) region ("location constraint is incompatible for the region specific endpoint")
body: <p>I keep on failing to use signed URLs for S3 objects residing in a bucket in the ap-east-1 (Hong Kong) AWS region.</p>
  
  <p>Specifically, I first set the signature version to V4 (see <a href="https://docs.aws.amazon.com/AmazonS3/latest/dev/UsingAWSSDK.html#specify-signature-version" rel="nofollow noreferrer">https://docs.aws.amazon.com/AmazonS3/latest/dev/UsingAWSSDK.html#specify-signature-version</a>) like so:</p>
  
  <pre><code>aws configure set default.s3.signature_version s3v4
  </code></pre>
  
  <p>And then create a signed URL with this command:</p>
  
  <pre><code>aws s3 presign --region=ap-east-1 s3://&lt;name of bucket in ap-east-1 region&gt;/&lt;object name&gt;
  </code></pre>
  
  <p>When I test the resulting URL:</p>
  
  <pre><code>curl -i "https://&lt;bucket name&gt;.s3.amazonaws.com/&lt;object name&gt;?X-Amz-Algorithm=AWS4-HMAC-SHA256&amp;X-Amz-Credential=...%2Fap-east-1%2Fs3%2Faws4_request&amp;X-Amz-Date=20190928T034534Z&amp;X-Amz-Expires=3600&amp;X-Amz-SignedHeaders=host&amp;X-Amz-Signature=..."
  </code></pre>
  
  <p>...I get an HTTP/400 response with the body set to:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;Error&gt;
     &lt;Code&gt;IllegalLocationConstraintException&lt;/Code&gt;
     &lt;Message&gt;The ap-east-1 location constraint is incompatible for the region specific endpoint this request was sent to. 
     &lt;/Message&gt;
     &lt;RequestId&gt;...&lt;/RequestId&gt;
  &lt;HostId&gt;
  </code></pre>
  
  <p>Interestingly, when doing the same for an object in another bucket that resides in the us-west-2 (Oregon) AWS region, the resulting signed URL works fine.</p>
  
  <p>Has anyone run into this problem? I don't quite know how to parse the error message, but I do wonder if I need to set the <code>--endpoint-url</code> configuration setting and if so, to what?</p>
  
  <p>Ideas anyone?</p>
  
  <p>Thanks,
  Soeren</p>