PyCharm Python Lambda 事件桥缺少 AWSEvent

PyCharm Python Lambda Event Bridge missing AWSEvent

我正在尝试根据 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)

关于如何解决这个问题的任何建议。那个class肯定不是生成在文件dir.

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

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