Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

JavaScript error when importing into python CDK stack #12447

Open
maBarabas opened this issue Feb 16, 2022 · 4 comments · May be fixed by aws-amplify/amplify-cli-export-construct#60
Open

JavaScript error when importing into python CDK stack #12447

maBarabas opened this issue Feb 16, 2022 · 4 comments · May be fixed by aws-amplify/amplify-cli-export-construct#60
Labels
bug Something isn't working export Issues related to cdk-exported-backend p2 transferred This issue was transferred from another Amplify project

Comments

@maBarabas
Copy link

When I try to import an Amplify app into a CDK stack defined in python I get the following error after cdk synth. The same amplify app imported into a JavaScript CDK stack works.

$ node --version
v16.13.2

$ cdk --version
2.8.0 (build 8a5eb49)

    # python dependencies setup
    install_requires=[
        "aws-amplify.cdk.exported-backend==0.0.5",
        "aws-cdk.core==1.137.0",
        "aws-cdk.aws-lambda==1.137.0",
        "aws-cdk.aws-lambda-python==1.137.0",
        "aws-cdk.aws-amplify==1.137.0",
        "aws-cdk.aws-iam==1.137.0",
    ],
    
    # JavaScript dependencies setup
  "dependencies": {
    "@aws-amplify/cdk-exported-backend": "^0.0.5",
    "@aws-cdk/core": "1.137.0",
    "@aws-cdk/aws-lambda": "1.137.0",
    "@aws-cdk/aws-lambda-python": "1.137.0",
    "@aws-cdk/aws-amplify": "1.137.0",
    "@aws-cdk/aws-iam": "1.137.0",
    "source-map-support": "^0.5.16"
  }

jsii.errors.JavaScriptError:
  node:internal/modules/cjs/loader:936
    throw err;
    ^

  Error: Cannot find module 'lodash'
  Require stack:
  - /tmp/jsii-kernel-7PvqTu/node_modules/@aws-amplify/cdk-exported-backend/lib/export-backend-asset-handler/index.js
  - /tmp/jsii-kernel-7PvqTu/node_modules/@aws-amplify/cdk-exported-backend/lib/export-backend.js
  - /tmp/jsii-kernel-7PvqTu/node_modules/@aws-amplify/cdk-exported-backend/lib/index.js
  - 2742
      at Function.Module._resolveFilename (node:internal/modules/cjs/loader:933:15)
      at Function.Module._load (node:internal/modules/cjs/loader:778:27)
      at Module.require (node:internal/modules/cjs/loader:1005:19)
      at require (node:internal/modules/cjs/helpers:102:18)
      at Object.<anonymous> (/tmp/jsii-kernel-7PvqTu/node_modules/@aws-amplify/cdk-exported-backend/lib/export-backend-asset-handler/index.js:10:11)
      at Module._compile (node:internal/modules/cjs/loader:1101:14)
      at Object.Module._extensions..js (node:internal/modules/cjs/loader:1153:10)
      at Module.load (node:internal/modules/cjs/loader:981:32)
      at Function.Module._load (node:internal/modules/cjs/loader:822:12)
      at Module.require (node:internal/modules/cjs/loader:1005:19)

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "app.py", line 12, in <module>
    from cdk_amplify_import_test.cdk_amplify_import_test_stack import CdkAmplifyImportTestStack
  File "/home/barabas/esp/cdk-amplify-import-test/cdk_amplify_import_test/cdk_amplify_import_test_stack.py", line 2, in <module>
    from aws_amplify.cdk.exported_backend import AmplifyExportedBackend
  File "/home/barabas/esp/cdk-amplify-import-test/.venv/lib/python3.8/site-packages/aws_amplify/cdk/exported_backend/__init__.py", line 74, in <module>
    from ._jsii import *
  File "/home/barabas/esp/cdk-amplify-import-test/.venv/lib/python3.8/site-packages/aws_amplify/cdk/exported_backend/_jsii/__init__.py", line 23, in <module>
    __jsii_assembly__ = jsii.JSIIAssembly.load(
  File "/home/barabas/esp/cdk-amplify-import-test/.venv/lib/python3.8/site-packages/jsii/_runtime.py", line 43, in load
    _kernel.load(assembly.name, assembly.version, os.fspath(assembly_path))
  File "/home/barabas/esp/cdk-amplify-import-test/.venv/lib/python3.8/site-packages/jsii/_kernel/__init__.py", line 269, in load
    self.provider.load(LoadRequest(name=name, version=version, tarball=tarball))
  File "/home/barabas/esp/cdk-amplify-import-test/.venv/lib/python3.8/site-packages/jsii/_kernel/providers/process.py", line 338, in load
    return self._process.send(request, LoadResponse)
  File "/home/barabas/esp/cdk-amplify-import-test/.venv/lib/python3.8/site-packages/jsii/_kernel/providers/process.py", line 326, in send
    raise JSIIError(resp.error) from JavaScriptError(resp.stack)
jsii.errors.JSIIError: Cannot find module 'lodash'
Require stack:
- /tmp/jsii-kernel-7PvqTu/node_modules/@aws-amplify/cdk-exported-backend/lib/export-backend-asset-handler/index.js
- /tmp/jsii-kernel-7PvqTu/node_modules/@aws-amplify/cdk-exported-backend/lib/export-backend.js
- /tmp/jsii-kernel-7PvqTu/node_modules/@aws-amplify/cdk-exported-backend/lib/index.js
- 2742

@maBarabas
Copy link
Author

pip freeze

$ python --version
Python 3.8.10

$ python -m pip --version
pip 22.0.3 from /home/barabas/esp/cdk-amplify-import-test/.venv/lib/python3.8/site-packages/pip (python 3.8)

@github-actions
Copy link

This issue is now marked as stale because it hasn't seen activity for a while. Add a comment or it will be closed soon.

@ammarkarachi ammarkarachi added the bug Something isn't working label Apr 25, 2022
@csotomon
Copy link

i am having the same issue, any update about this bug?

Cli:
aws-cdk 2.72.1

Python packages:
aws-amplify.cdk.exported-backend==0.0.6
aws-cdk-lib==2.72.1
constructs>=10.0.0,<11.0.0

@ykethan ykethan transferred this issue from aws-amplify/amplify-cli-export-construct Apr 12, 2023
@ykethan ykethan added pending-triage Issue is pending triage extensibility Issues related to expand or customize current configuration transferred This issue was transferred from another Amplify project export Issues related to cdk-exported-backend and removed bug Something isn't working extensibility Issues related to expand or customize current configuration labels Apr 12, 2023
@josefaidt josefaidt added the pending-review Pending review from core-team label Apr 13, 2023
@josefaidt josefaidt removed the pending-review Pending review from core-team label Apr 25, 2023
@josefaidt josefaidt self-assigned this Apr 25, 2023
@josefaidt josefaidt added bug Something isn't working and removed pending-triage Issue is pending triage labels May 2, 2023
@josefaidt josefaidt removed their assignment May 2, 2023
@josefaidt josefaidt added p3 p2 and removed p3 labels May 2, 2023
@martonjuhasz98
Copy link

I'm having the same issue still. Is there an expected time to fix this?

CLI:
aws-cdk 2.99.1

requirements.txt
aws-amplify.cdk.exported-backend==0.0.6
aws-cdk-lib==2.97.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working export Issues related to cdk-exported-backend p2 transferred This issue was transferred from another Amplify project
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants