rails-lambda / lamby

🐑🛤 Simple Rails & AWS Lambda Integration
https://lamby.cloud
MIT License
602 stars 29 forks source link

EventBridge Guide #103

Open metaskills opened 3 years ago

metaskills commented 3 years ago

I forgot we built in EventBridge support and need to add some guides around it. Here is the PR outlining the features. https://github.com/customink/lamby/pull/82 We will need docs on permissions and rules. For ex:

EventBridgeRule:
  Type: AWS::Events::Rule
  Properties:
    Description: String
    EventBusName: arn:aws:events:us-east-1:123456789012:event-bus/merchandising
    EventPattern: { "source": [ "myorg.products@StyleUpdate" ], "detail-type": [ "PricingChange" ] }
    Targets:
      - Arn: !GetAtt RailsLambda.Arn
        Id: MyAppProductUpdates
        RetryPolicy:
          MaximumRetryAttempts: 10
          MaximumEventAgeInSeconds: 400

EventBridgeLambdaPermission:
  Type: AWS::Lambda::Permission
  Properties:
    FunctionName:
      Ref: "RailsLambda"
    Action: "lambda:InvokeFunction"
    Principal: "events.amazonaws.com"
    SourceArn: !GetAtt EventBridgeRule.Arn

It might be cool to explore a few handler alternative steps. Like maybe promote a single PORO. Maybe the Lamby interface could include some source interface patterns.