1

我正在尝试基于 AWS Event Bridge 架构在 pycharm 中设置一个基本的 AWS Lambda。然而,在生成框架代码并尝试运行 Lambda 后,它抱怨导入失败:

from schema.payload_report_event import AWSEvent
{"errorType":"Runtime.ImportModuleError","errorMessage":"Unable to import module 'hello_world/app': cannot import name 'AWSEvent' from 'schema.payload_report_event' (/var/task/schema/payload_report_event/__init__.py)"}
# Deserialize event into strongly typed object
aws_event: AWSEvent = Marshaller.unmarshall(event, AWSEvent)
detail: PayrollReportRequest = aws_event.detail

# Execute business logic

# Make updates to event payload, if desired
aws_event.detail_type = "HelloWorldFunction updated event of " + aws_event.detail_type

# Return event for further processing
return Marshaller.marshall(aws_event)

关于如何解决此问题的任何建议。该类肯定不会在文件目录中生成。

4

1 回答 1

0

通过基于不同的 SAM 模板生成新项目来设法找到解决方法:

在此处输入图像描述

而不是从头开始(对于事件模式)选项。在这种情况下,会生成 aws_event.py 文件,并且可以对其进行修改以设置适当的 Detail 类型。这似乎确实是工具中某处的错误,但会检查问题跟踪器并尝试提交到相关项目。

于 2020-12-09T08:55:00.777 回答