-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
12 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,44 +1,29 @@ | ||
# Magento 2 Eventbridge Notifier | ||
|
||
This repository adds an [aligent/async-events](https://github.com/aligent/magento-async-events) compatible notifier for submitting events to [Amazon EventBridge](https://aws.amazon.com/eventbridge/). | ||
|
||
## How to use | ||
This module only provides an implementation of the `EventBridgeNotifier`. The `NotifierFactoryInterface` does not know anything about it yet. Therefore, it must be hooked up to the factory depending on the implementation of the `NotifierFactory`. | ||
## Getting Started | ||
|
||
1. Hook the notifier to the notifier factory | ||
* This depends on how your factory is setup, if you're using the reference implementation for `NotifierFactoryInterface`, then you have to add the following lines | ||
to a `di.xml` | ||
### Configure AWS Credentials | ||
An IAM role with the `events:PutEvents` action is required so that the notifier can relay events into Amazon EventBridge. | ||
|
||
```xml | ||
<type name="Aligent\AsyncEvents\Service\AsyncEvent\NotifierFactory"> | ||
<arguments> | ||
<argument name="notifierClasses" xsi:type="array"> | ||
<item name="event_bridge" xsi:type="object">Aligent\EventBridge\Service\EventBridgeNotifier</item> | ||
</argument> | ||
</arguments> | ||
</type> | ||
``` | ||
2. Run `bin/magento cache:clear` | ||
3. Create subscribers which use the new notifier using the `metadata` field. | ||
Under `Stores -> Services -> Amazon EventBridge` set the `Access Key ID` and the `Secret Access Key` and the `Region`. You | ||
can configure the source of the event and the event bus if necessary. | ||
|
||
![AWS Config](./docs/config.png) | ||
|
||
### Create Subscription | ||
|
||
Example | ||
```sh | ||
```shell | ||
curl --location --request POST 'https://m2.dev.aligent.consulting:44356/rest/V1/async_event' \ | ||
--header 'Authorization: Bearer TOKEN' \ | ||
--header 'Content-Type: application/json' \ | ||
--data-raw '{ | ||
"asyncEvent": { | ||
"event_name": "my.custom.hook", | ||
"event_name": "example.event", | ||
"recipient_url": "Amazon Event Bridge ARN", | ||
"verification_token": "supersecret", | ||
"metadata": "event_bridge" | ||
} | ||
}' | ||
``` | ||
|
||
### Configuring AWS Credentials | ||
An IAM role with the `events:PutEvents` action is required so that the notifier can relay events into Amazon EventBridge. | ||
|
||
Under `Stores -> Services -> Amazon EventBridge` set the `Access Key ID` and the `Secret Access Key` and the `Region`. You | ||
can configure the source of the event and the event bus if necessary. | ||
|
||
![AWS Config](./docs/config.png) |