title: AWS python lambda - difference in importing module in lambda than from local project
body: <p>I am havin an issue with importing a common function util file in my AWS lambda. It is a python file and the folder structure looks something like this</p>
  <pre><code>(functions folder)
     common_util.py
     (lambda 1 folder)
        lambda1
     (lambda 2 folder)
        lambda2
  </code></pre>
  <p>I need to access the common_util from both these lambdas. When I run my CDK project locally this is easy i use something like <code>..</code> on the import statement to tell the file it is one directory up</p>
  <pre><code>from ..common_util import (...)
  </code></pre>
  <p>When I deploy to AWS as a lambda (I package all of the above) I need to specify the import without the <code>..</code> because this is the root folder of the lambda</p>
  <pre><code>from common_util import(...)
  </code></pre>
  <p>I need an import statement or a solution that will work for both my CDK project and the lambda.</p>
  <p>here is the CDK where the lambda is created</p>
  <pre><code>const noteIntegrationLambda = new Function(this as any,&quot;my-lambda&quot;,
        {
          functionName:
            &quot;my-lambda&quot;,
          runtime: StackConfiguration.PYTHON_VERSION,
          handler:
            &quot;my_lambda.execute&quot;,
          timeout: Duration.seconds(15),
          code: Code.fromAsset(&quot;functions/&quot;),
          role,
          layers: [dependencyLayer],
          environment: env,
  
          },
        }
      );
  </code></pre>