スキップしてコンテンツを表示

Lambda with layers: Runtime.ImportModuleError: Unable to import module

0

The zip file structure looks as expected by lambda so not sure why I am getting this error. My lambda function is main-lambda.py and it directly at the root of the zip/folder structure - folder-structure Runtime config: Runtime Python 3.12 HandlerInfo main-lambda.lambda_handler ArchitectureInfo x86_64

Structure:- nupeacock-main-backend |nupeacock-backend-for-aws.zip | main-lambda.py

質問済み 2年前1367ビュー

2回答
1

Firstly, it appears that your lambda function code is nested inside the zip file/folder - which seems to be your library (nupeacock-backend-for-aws.zip)? Try moving your Lambda function code up to the root folder (nupeacock-main-backend) and run test again. It could be that your Lambda function code couldn't find the path to your library.

Secondly, you mentioned "layers", are your libraries deployed as Lambda Layer? Or you intend to just refer to your libraries as path-relative to your Lambda function as you did above?

回答済み 2年前

  • Yes, already tried it and it works now.

0

Hello,

Python 3.12 is based on an Amazon Linux 2023 Amazon Machine Image (AMI). So, create the layer on an Amazon Linux 2023 OS.

Follow this article to troubleshoot this error , https://repost.aws/knowledge-center/lambda-import-module-error-python

エキスパート

回答済み 2年前

  • thank you for your response but the issue is with calling the main lambda handler function itself (which is correctly located in the root folder of zip) and not with dependencies so not sure I agree with your response.

ログインしていません。 ログイン 回答を投稿する。

優れた回答とは、質問に明確に答え、建設的なフィードバックを提供し、質問者の専門分野におけるスキルの向上を促すものです。

関連するコンテンツ