Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Issue with EventBridge rule for aws.events

I want to send to CloudWatch logs ALL the events sent to a custom event bus.

I created the custom event bus: my-event-bus

I created the CloudWatch log group

I created the event bus policy so everyone within my account can put an event into my-event-bus

I created a rule for that custom bus

This is the rule:

  MyRuleForBus:
    Type: AWS::Events::Rule
    Properties:
      Description: Testing rule
      EventBusName: 
      Name: testing-rule-for-my-event-bus
      EventPattern:
        source:
          - aws.events
      State: ENABLED
      Targets:
        - Arn: arn:aws:logs:us-east-1:MY_ACCOUNT_ID:log-group:my-event-bus-log-group
          Id: 'my-bus'

When I try to put an event aws events put-events --entries file://put-events.json

I receive the following error

{
    "FailedEntryCount": 1,
    "Entries": [
        {
            "ErrorCode": "NotAuthorizedForSourceException",
            "ErrorMessage": "Not authorized for the source."
        }
    ]
}

This is the content of put-events.json

[
    {
      "Source": "aws.events",
      "EventBusName": "my-event-bus",
      "Detail": "{ \"key1\": \"value3\", \"key2\": \"value4\" }",
      "Resources": [
        "resource1",
        "resource2"
      ],
      "DetailType": "myDetailType"
     }
  ]

But, if I change the source to other, for example, 'hello', in both, the rule and the event it works.

What am I doing wrong? I want to make it work with aws.events so all the events sent to this bus end in CloudWatch (target)

like image 850
Peter Avatar asked May 20 '21 23:05

Peter


People also ask

Is EventBridge the same as CloudWatch events?

EventBridge is the evolution of the CloudWatch Events service. It brings new features, including the ability to integrate data from popular SaaS providers as events within AWS.

How many rules can EventBridge create?

EventBridge can be used to implement modest message fanout. A rule can trigger up to 5 targets. By default, you can create 300 rules per event bus (a soft limit that can be increased; the hard limit is not disclosed).


Video Answer


1 Answers

aws.events belongs to AWS, not to you, thus you can't define it as source of your events. Only AWS can do it.

You need to use your own custom name for the source of your events, e.g. myapp.events.

like image 200
Marcin Avatar answered Oct 22 '22 08:10

Marcin