Search code examples
pythonaws-lambdapycharmaws-samaws-event-bridge

PyCharm Python Lambda Event Bridge missing AWSEvent


I am trying to setup a basic AWS Lambda in pycharm based on an AWS Event Bridge schema. However after generating the framework code and attempting to run the Lambda it is complaining about a failing import on:

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)

Any suggestions on how I can resolve this. That class is certainly not generated in the file dir.


Solution

  • Managed to find a workaround by generating a new project based on a different SAM template:

    enter image description here

    Rather than the from Scratch (for an Event schema) option. In this case the aws_event.py file is generated and can be modified to have the appropriate Detail type set. This does seem to be a bug somewhere along the line in the tooling though so will check the issue trackers and try submit to relevant project.