Can we have multiple AWS events or EventBridge partner events in a single event rule

0

I'm looking to create a single event rule and have multiple patterns in it. patterns like ACM Certificate Approaching Expiration & EC2 Instance State-change Notification. if one of the these 2 patterns matches with there corresponding resources then i have target lambda these will perform an action based on some input values from the event.

  1. Suggest me is it good idea to have a single rule and multiple patterns
  2. I know there is a Custom events. Will it help to solve this case
  3. If don't want to prefer this custom events because of cost. Correct me if I'm wrong - AWS default service events Free of cost. whereas Custom events $1.00/million custom events published
2 個答案
1
已接受的答案

Custom events are events that you generate in your application. I am not sure how you want to use custom events in this case. The only way I can think of is to create rules that catch the other, AWS, events, and then create a new custom event. If you do that anyway, why do you need the custom event, not to mention the extra cost and complexity.

You can combine multiple events into a single rule. For instance, the following rule will check if the event is EC2 instance change or ACM certificate expiration:

{
  "source": ["aws.ec2"],
  "detail-type": ["EC2 Instance State-change Notification", "ACM Certificate Approaching Expiration"]
}

You can also have more complex rules such as:

{
  "$or": [
    {
      "detail-type": ["EC2 Instance State-change Notification"],
      "detail": { "state": ["pending"] }
    },
    {
      "detail-type": ["ACM Certificate Approaching Expiration"],
      "detail": { "DaysToExpiry":  [ { "numeric": [ "<", 10 ] } ] }
    }
  ]
}
profile pictureAWS
專家
Uri
已回答 1 年前
profile picture
專家
已審閱 5 個月前
1

Yes, it is possible to have multiple patterns in a single event rule using AWS EventBridge. Each pattern can be associated with different event sources or services. In your case, you can create a single event rule with multiple patterns, such as one pattern for ACM Certificate Approaching Expiration and another pattern for EC2 Instance State-change Notification.

By using a single event rule with multiple patterns, you can consolidate the logic and actions within a single rule. This approach can simplify your event handling and reduce the number of separate rules you need to manage.

Regarding Custom Events, they are a feature of EventBridge that allows you to define your own custom events and publish them to the event bus. While Custom Events offer flexibility, they do incur additional costs. AWS default service events, on the other hand, are provided by AWS services and are generally free of cost.

If you prefer to avoid the additional cost associated with Custom Events, you can stick with using the default service events provided by AWS services like ACM and EC2. By combining multiple patterns within a single event rule, you can achieve your desired functionality efficiently.

profile picture
Amol_M
已回答 1 年前
profile picture
專家
已審閱 1 個月前

您尚未登入。 登入 去張貼答案。

一個好的回答可以清楚地回答問題並提供建設性的意見回饋,同時有助於提問者的專業成長。

回答問題指南