title: Lambda / Pre-signed url access denied
body: <p>I wrote a lambda function who return a pre-signed url for documents in S3 Buckets.</p>
  
  <p>The code is really simple :</p>
  
  <pre><code>            const url = s3.getSignedUrl('getObject', {
                  Bucket: BUCKET_NAME,
                  Key: myFile.Key,
                  Expires: 20
              })
  
              const response = {
                  statusCode: 200,
                  headers: {
                      "Access-Control-Allow-Origin": "*"
                  },
                  body: JSON.stringify({
                      "url": url
                  }),
              };
  </code></pre>
  
  <p>The funny thing is when I call this function locally (with serverless framework) like this :</p>
  
  <pre><code>sls invoke local -f getEconomyFile -d '{ "queryStringParameters": { "key": "myfile.pdf" } }'
  </code></pre>
  
  <p>It's working ! I have a url which give me the file.</p>
  
  <p>But when I deploy to AWS Lambda, the function return a URL which always says "access denied" on the file :</p>
  
  <pre><code>&lt;Error&gt;
      &lt;Code&gt;AccessDenied&lt;/Code&gt;
      &lt;Message&gt;Access Denied&lt;/Message&gt;
      &lt;RequestId&gt;93778EA364B3506B&lt;/RequestId&gt;
      &lt;HostId&gt;
          yqnPC0SeIVE3/Pl7/d+xHDJ78=
      &lt;/HostId&gt;
  &lt;/Error&gt;
  </code></pre>
  
  <p>Why is it working locally and not deployed ? </p>
  
  <p>Thank you !</p>