def lambda_handler()

in blog/account-a-web-store/order_function/app.py [0:0]


def lambda_handler(event, context):

  # new order created event detail
  eventDetail  = {
    "orderNo": "123",
    "orderDate": "2020-09-09T22:01:02Z",
    "customerId": "789",
    "lineItems": {
      "productCode": "P1",
      "quantityOrdered": 3,
      "unitPrice": 23.5,
      "currency": "USD"
    }
  }

  try:
    # Put an event
    response = events.put_events(
        Entries=[
            {
                'EventBusName': EVENT_BUS_ARN,
                'Source': 'com.exampleCorp.webStore',
                'DetailType': 'newOrderCreated',
                'Detail': json.dumps(eventDetail)
            }
        ]
    )
    print(response['Entries'])
    print(f"Event sent to the event bus {EVENT_BUS_ARN}")
    print(f"EventID is {response['Entries'][0]['EventId']}")
  except Exception as e:
      print(e)