title: Invoking a file from AWS lambda handler.js?
body: <p>I have node.js file(i.e.<code>abc.js</code>) which will give the output when i run in my node.js editor. I want to run the same file in <code>AWS Lambda</code>.For that, I created a lambda and moved <code>abc.js</code> to there. To run, it seems i need to implement my <code>abc.js</code> file in handler.js(i.e.in lambda way means callback etc).</p>
  
  <p>Is there any way to trigger <code>abc.js</code> from <code>handler.js</code> rather than implementing again the same thing in <code>handler.js</code>?</p>
  
  <p>Checked regarding the above usecase but didn't find much on google.</p>
  
  <p><strong>Updated</strong></p>
  
  <p>My abc.js file</p>
  
  <pre><code>var AWS = require('aws-sdk');
  // Set the region 
  AWS.config.update({
      region: "ap-south-1"
     });
  
  // Create S3 service object
  s3 = new AWS.S3();
  var params= {};
   s3.listBuckets(params, bucketList);
  function bucketList(err, data) {
    if (err) console.log(err, err.stack); // an error occurred
    else   
    {   
          console.log(data)
    }
  }
  </code></pre>
  
  <p>My handler.js in lambda and modifying it based on my interpretation of your answer.</p>
  
  <pre><code>exports.handler = async (event) =&gt; {
      const abc = require('./abc.js');
      // TODO implement
  abc.bucketList();     
  };
  </code></pre>
  
  <p>This is the error i am getting</p>
  
  <pre><code>Response:
  {
    "errorMessage": "abc.bucketList is not a function",
    "errorType": "TypeError",
    "stackTrace": [
      "exports.handler (/var/task/index.js:5:5)"
    ]
  }
  </code></pre>
  
  <p>Any help is appreciated.</p>