amazon-web-servicesaws-lambdazappaaws-event-bridge

Zappa trigger lambda from EventBridge pattern


I have the following event pattern that I want my lambda function to be triggered from but i'm unable to find any documentation to allow this to be set in the zappa_settings.json file. I'm only able to find SNS and EventBridge cron expressions.

{
  "source": ["aws.ec2"],
  "detail-type": ["AWS API Call via CloudTrail"],
  "detail": {
    "eventSource": ["ec2.amazonaws.com"],
    "eventName": ["RunInstance"]
  }
}

How can I get my lambda function to create and trigger from this event?


Solution

  • I can add an SNS topic as a trigger to the lambda function and point EventBridge at the topic. Not perfect as the UI allows EventBridge to trigger Lambda functions directly but it works. Just need to add the following into the zappa_settings file and setup the EventBridge outside zappa.

    "events": [
        {
            "function": "auto_tagger.lambda_handler",
            "event_source": {
                "arn":  "arn:aws:sns:eu-west-1:1234567890:trigger-test",
                "events": [
                     "sns:Publish"
                ]
            }
        }
    ]