title: Amplify: how to require/import custom function from lambda layer?
body: <p>I have an Amplify project where I would like to use lambda layers. The layer and lambda have been configured using Amplify CLI.</p>
  <p>Lambda layer in named as 'common'. The file is <code>./amplify/backend/function/common/opt/param.js</code>. It exports one function:</p>
  <pre><code>const getValue = async (name) =&gt; {
  ...
  }
  module.exports = getValue;
  </code></pre>
  <p>In my lambda function I would like to use the above helper function. However, I do not know how to import this. I have tried:</p>
  <pre><code>const getValue = require('param');
  const getValue = require('./param');
  const getValue = require('/opt/param');
  const getValue = require('./opt/param');
  </code></pre>
  <p>but they all fail with error like:</p>
  <pre><code>&quot;errorType&quot;: &quot;Runtime.ImportModuleError&quot;,
      &quot;errorMessage&quot;: &quot;Error: Cannot find module '/opt/param'
  </code></pre>
  <p>Note also that I have updated the lambda after pushing the layer and its connected to the latest layer version. So the code should be available for the lambda.</p>