Nodejs AWS SDK S3 Generate Presigned URL
<p>I am using the NodeJS AWS SDK to generate a presigned S3 URL. The docs give an <a href="https://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/S3.html#getSignedUrl-property" rel="noreferrer">example of generating a presigned URL</a>.</p>

<p>Here is my exact code (with sensitive info omitted):</p>

<pre><code>const AWS = require('aws-sdk')

const s3 = new AWS.S3()
AWS.config.update({accessKeyId: 'id-omitted', secretAccessKey: 'key-omitted'})

// Tried with and without this. Since s3 is not region-specific, I don't
// think it should be necessary.
// AWS.config.update({region: 'us-west-2'})

const myBucket = 'bucket-name'
const myKey = 'file-name.pdf'
const signedUrlExpireSeconds = 60 * 5

const url = s3.getSignedUrl('getObject', {
    Bucket: myBucket,
    Key: myKey,
    Expires: signedUrlExpireSeconds
})

console.log(url)
</code></pre>

<p>The URL that generates looks like this:</p>

<pre><code>https://bucket-name.s3-us-west-2.amazonaws.com/file-name.pdf?AWSAccessKeyId=[access-key-omitted]&amp;Expires=1470666057&amp;Signature=[signature-omitted]
</code></pre>

<p>I am copying that URL into my browser and getting the following response:</p>

<pre><code>&lt;Error&gt;
  &lt;Code&gt;NoSuchBucket&lt;/Code&gt;
  &lt;Message&gt;The specified bucket does not exist&lt;/Message&gt;
  &lt;BucketName&gt;[bucket-name-omitted]&lt;/BucketName&gt;
  &lt;RequestId&gt;D1A358D276305A5C&lt;/RequestId&gt;
  &lt;HostId&gt;
    bz2OxmZcEM2173kXEDbKIZrlX508qSv+CVydHz3w6FFPFwC0CtaCa/TqDQYDmHQdI1oMlc07wWk=
  &lt;/HostId&gt;
&lt;/Error&gt;
</code></pre>

<p>I know the bucket exists. When I navigate to this item via the AWS Web GUI and double click on it, it opens the object with URL and works just fine:</p>

<pre><code>https://s3-us-west-2.amazonaws.com/[bucket-name-omitted]/[file-name-omitted].pdf?X-Amz-Date=20160808T141832Z&amp;X-Amz-Expires=300&amp;X-Amz-Algorithm=AWS4-HMAC-SHA256&amp;X-Amz-Signature=[signature-omitted]&amp;X-Amz-Credential=ASIAJKXDBR5CW3XXF5VQ/20160808/us-west-2/s3/aws4_request&amp;X-Amz-SignedHeaders=Host&amp;x-amz-security-token=[really-long-key]
</code></pre>

<p>So I am led to believe that I must be doing something wrong with how I'm using the SDK.</p>