# ※書き途中の内容です。 ## 問題 Amplifyで作成したプロジェクトでamplify pushを使ってデプロイしたLambdaを実行すると`[ERROR] Runtime.ImportModuleError: Unable to import module 'index': urllib3 v2.0 only supports OpenSSL 1.1.1+, currently the 'ssl' module is compiled with 'OpenSSL 1.0.2k-fips`というエラーが発生する。 ## そもそも実現したいこと LambdaでLangChainを使ってPineconeからフロントで入力された質問に対する回答をフロントに返したい。 ## 行った手順 amplify pushでLambdaをデプロイしたところ、`[ERROR] Runtime.ImportModuleError: Unable to import module 'index': urllib3 v2.0 only supports OpenSSL 1.1.1+, currently the 'ssl' module is compiled with 'OpenSSL 1.0.2k-fips`というエラーが発生 ## 解決策 OpenSSLのバージョンを1.1.1+に変更 ## 次に発生したエラー ``` [ERROR] Runtime.ImportModuleError: Unable to import module 'index': urllib3 v2.0 only supports OpenSSL 1.1.1+, currently the 'ssl' module is compiled with 'OpenSSL 1.0.2k-fips ``` → pip install urllib3で解決 ------------------------------------------- ## 次に発生したエラー ``` [ERROR] Runtime.ImportModuleError: Unable to import module ‘index’: IMPORTANT: PLEASE READ THIS FOR ADVICE ON HOW TO SOLVE THIS ISSUE! Importing the numpy C-extensions failed. This error can happen for many reasons, often due to issues with your setup or how NumPy was installed. We have compiled some common reasons and troubleshooting tips at: https://numpy.org/devdocs/user/troubleshooting-importerror.html Please note and check the following: * The Python version is: Python3.8 from “/var/lang/bin/python3.8” * The NumPy version is: “1.24.4" and make sure that they are the versions you expect. Please carefully study the documentation linked above for further help. Original error was: No module named ‘numpy.core._multiarray_umath’ Traceback (most recent call last): ``` → 多分NumPyは1.24.4を入れて解決 ## 別に発生したエラー ``` The following resources failed to deploy: Resource Name: LambdaFunction (AWS::Lambda::Function) Event Type: update Reason: Resource handler returned message: "Unzipped size must be smaller than 135390475 bytes (Service: Lambda, Status Code: 400, Request ID: a3b51e9a-4734-435e-a001-2c7ce1301ee7)" (RequestToken: 92a2a218-8b38-6b12-baff-133e7d710537, HandlerErrorCode: InvalidRequest) URL: https://console.aws.amazon.com/cloudformation/home?region=ap-northeast-1#/stacks/arn%3Aaws%3Acloudformation%3Aap-northeast-1%3A237156174022%3Astack%2Famplify-slackbottesttwo-dev-162215-functionslackLangchainResponder-1PUTGEZ3KV53F%2F6707b020-344c-11ee-a124-0e162f03cf95/events ``` →以下の手順で解決 1. pipenvでインストールしたパッケージを記録 1. pipenvでインストールしたパッケージをアンインストール 1. 1.で記録したパッケージを元にLambdaレイヤー作成 ■レイヤーの作り方 1. Lambdaで「レイヤー」選択 2. レイヤーの作成 3. 対象zipアップロード 4. x84_64選択 5. ランタイム:python3.8選択 6. 対象関数で「レイヤーの追加」ボタン押下 7. カスタムレイヤーで作ったレイヤー選択