title: Get File From S3 bucket using Serverless and Node js
body: <p>I am new to Serverless and AWS also. So My requirement is like. I need to download a file from S3. I have tried in many ways. I read many articles but could not find a proper document for this purpose.</p>
  
  <p>So What I did was, I created a boilerplate using Serverless and got all the files like handler.js, serverless.yml</p>
  
  <p>I need to know the correct steps to download a file from S3.</p>
  
  <p>What I tried is.
   Handler.js</p>
  
  <pre><code>const AWS = require('aws-sdk');
  const S3= new AWS.S3();
  exports.hello = async (event, context) =&gt; {
    console.log(`Hi from Node.js ${process.version} on Lambda!`)
    S3.getObject({Bucket: '*******', Key: '******'}).promise().then( data =&gt;{
      return {
        statusCode: 200,
        body: data
    })
  }
  </code></pre>
  
  <p>Serveless.yml</p>
  
  <pre><code>service: node11
  
  custom:
    bucket: *********
  
  provider:
    name: aws
    runtime: provided # set to provided
    stage: dev
    region: us-east-1
    iamRoleStatements:
      - Effect: Allow
        Action:
          - s3:*
        Resource: "arn:aws:s3:::${self:custom.bucket}/*"
  
  functions:
    hello:
      handler: handler.hello
      events:
        - http:
            path: /
            method: get
      layers: # add layer
        - arn:aws:lambda:us-east-1:553035198032:layer:nodejs11:3
  </code></pre>
  
  <p>Whatever I did, I am always getting an error like INTERNAL SERVER ERROR.</p>
  
  <p>What is the proper way to get the file from S3?</p>