title: Accessing Lambda context object in other files
body: <p>I have a NodeJS AWS Lambda function which contains of multiple files. In the index.js I do the regular <code>exports.handler = function (event,context) {…}</code>.</p>
  
  <p>I also have a config.js file which handles various settings and module.exports a config object. This config file is required in several other files that all need access to these settings (default values, db settings, etc.). I don't necessarily need to use it in index.js itself.</p>
  
  <p>However, I need to set some settings inside the config module according to the alias of the Lambda function (for example which DynamoDB table suffix to use). While it's no problem to get the alias name via <code>context.invokedFunctionArn</code> (in my case PROD or STAGE) inside exports.handler, I don't have access to it in my config file (which is required all over the place).</p>
  
  <p>What would be the best way to make the context object available in my config module and how would I do it without running into circular dependencies (because it is needed before exports.handler is finished)?</p>
  
  <p>Inside exports.handler a lot of async code from multiple files which all require the config is executed. They all need to know which alias is running.</p>
  
  <p>The question is less about how to use aliases but more how to make the context object available in other files.</p>
  
  <p>Thanks! </p>