title: aws_cdk python error: Unzipped size must be smaller than 262144000 bytes
body: <p>I use CDK to deploy a lambda function that uses several python modules.
  But I got the following error at the deployment.</p>
  <pre><code>Unzipped size must be smaller than 262144000 bytes (Service: AWSLambdaInte
  rnal; Status Code: 400; Error Code: InvalidParameterValueException;
  </code></pre>
  <p>I have searched following other questions, related to this issue.</p>
  <p><a href="https://stackoverflow.com/questions/45342990/aws-lambda-error-unzipped-size-must-be-smaller-than-262144000-bytes">question1</a>
  <a href="https://stackoverflow.com/questions/59931761/unzipped-size-must-be-smaller-than-262144000-bytes-aws-lambda-error">question2</a></p>
  <p>But they focus on serverless.yaml and don't solve my problem.
  Is there any way around for this problem?</p>
  <p>Here is my app.py for CDK.</p>
  <pre><code>from aws_cdk import (
      aws_events as events,
      aws_lambda as lam,
      core,
  )
  
  class MyStack(core.Stack):
      def __init__(self, app: core.App, id: str) -&gt; None:
          super().__init__(app, id)
  
          layer = lam.LayerVersion(
              self, &quot;MyLayer&quot;,
              code=lam.AssetCode.from_asset('./lib'),
          );
  
          makeQFn = lam.Function(
              self, &quot;Singleton&quot;, 
              function_name='makeQ',
              code=lam.AssetCode.from_asset('./code'),
              handler=&quot;makeQ.main&quot;,
              timeout=core.Duration.seconds(300),
              layers=[layer],
              runtime=lam.Runtime.PYTHON_3_7,
          )
  
  
  app = core.App()
  MyStack(app, &quot;MS&quot;)
  app.synth()
  </code></pre>
  <p>In ./lib directory, I put python modules like,</p>
  <pre><code>python -m pip install numpy -t lib/python
  </code></pre>