Abdul Samad Farooqi
Abdul Samad Farooqi

Reputation: 1

How to Put Events to custom bus using aws php sdk?

I am trying to send an event to custom event bus 'custom-event-bus' using AWS PHP SDK using the following code

$client->putEvents([
    'Entries' => [ // REQUIRED
        [
            'Detail' => '{"alpha":"beta"}',
            'DetailType' => '',
            'EventBusName' => 'custom-event-bus',
            'Resources' => ['arn:aws:events:us-east-1:351123639451:event-bus/custom-event-bus',],
            'Source' => 'my-application',
            'Time' =>  time(),
        ],
     ],
]);

I am getting this error in the result:

AccessDeniedException (client): User: arn:aws:iam::351123639451:user/my-user is not authorized to perform: events:PutEvents on resource: arn:aws:events:us-east-1:351123639451:event-bus/default - {"__type":"AccessDeniedException","Message":"User: arn:aws:iam::351123639451:user/my-user is not authorized to perform: events:PutEvents on resource: arn:aws:events:us-east-1:351123639451:event-bus/default"}

From this error message, it seems to be that it is sending an event on the default event bus, not the custom one to which I am sending.

Upvotes: 0

Views: 1136

Answers (1)

Chris Williams
Chris Williams

Reputation: 35188

The syntax here is correct, EventBusName is where you would specify the event bus name.

I would recommend checking that you have no other calls to this function name, perhaps taking it out and running independently.

Upvotes: 0

Related Questions