title: AWS Lambda packaging with dependencies
body: <p>Further outlining is in the context of NodeJS and Monorepo (based on Lerna).</p>
  <p>I have AWS stack with several AWS Lambda inside deployed by means of AWS CloudFormation. Some of the lambdas are simple (the single small module) and could be inlined:</p>
  <p><a href="https://docs.aws.amazon.com/cdk/api/latest/docs/@aws-cdk_aws-lambda.Code.html#static-from-wbr-inlinecode" rel="nofollow noreferrer">https://docs.aws.amazon.com/cdk/api/latest/docs/@aws-cdk_aws-lambda.Code.html#static-from-wbr-inlinecode</a></p>
  <pre><code>const someLambda = new Function(this, 'some-lambda', {
    code: Code.fromInline(fs.readFileSync(require.resolve(&lt;relative path to lambda module&gt;), 'utf-8')),
    handler: 'index.handler',
    runtime: Runtime.NODEJS_12_X
  });
  </code></pre>
  <p>Some have no dependencies and packaged as follows:</p>
  <pre><code>const someLambda = new Function(this, 'some-lambda', {
    code: Code.fromAsset(&lt;relative path to folder with lambda&gt;),
    handler: 'index.handler',
    runtime: Runtime.NODEJS_12_X
  });
  </code></pre>
  <p>But in case of relatively huge lambdas with dependencies, as I understand, we only way to package (proposed by API) is <code>@aws-cdk/aws-lambda-nodejs</code>:</p>
  <pre><code>import * as lambdaNJS from &quot;@aws-cdk/aws-lambda-nodejs&quot;;
  
  export function createNodeJSFunction(
    scope: cdk.Construct, id: string, nodejsFunctionProps: Partial&lt;NodejsFunctionProps&gt;
  ) {
    const params: NodejsFunctionProps = Object.assign({
      parcelEnvironment: { NODE_ENV: 'production' },
    }, nodejsFunctionProps);
  
    return new lambdaNJS.NodejsFunction(scope, id, params);
  }
  </code></pre>
  <p>For standalone packages, it works well, but in case of the monorepo it just hangs on <code>synth</code> of the stack.
  I just looking for alternatives, cause I believe it is not a good idea to bundle (<code>parcel</code>) BE sources.</p>