Built by

ikhvost

Category

Other

Version

2.0.0

Last updated

Nov 1, 2024, 21:00:09 PM2 months ago

medusa-event-bus-aws

Overview

The Copy to clipboardmedusa-event-bus-aws package is a specialized solution designed to bridge Medusa v2.x, an extensible open-source headless commerce platform, with AWS EventBridge, an event bus service offered by Amazon Web Services (AWS). This package provides an efficient and streamlined approach for developers to integrate Medusa's core system with AWS services, enhancing the capabilities and reach of Medusa-based e-commerce solutions.
Note: Currently, this package does not support subscribing to events directly within the Medusa application. This is a feature we hope to add in the future. Contributions towards this are highly welcomed and appreciated.

Compatibility

This plugin requires Medusa v2.x or higher. It's specifically designed to work with Medusa's new modular architecture introduced in version 2.0.
  • ✅ Medusa v2.x
  • ❌ Medusa v1.x (use plugin version 1.x instead)

Installation

  1. Install the plugin via npm:
npm install medusa-event-bus-aws
or with yarn
yarn add medusa-event-bus-aws
or with pnpm
pnpm add medusa-event-bus-aws
  1. Add the plugin to your Copy to clipboardmedusa-config.ts:
export default defineConfig({
modules: {
[Modules.EVENT_BUS]: {
resolve: 'medusa-event-bus-aws',
options: {
region: process.env.AWS_REGION,
credentials: {
accessKeyId: process.env.AWS_ACCESS_KEY_ID,
secretAccessKey: process.env.AWS_SECRET_ACCESS_KEY,
},
eventBusName: process.env.AWS_EVENT_BUS_NAME
}
},
// other modules
},
projectConfig: { ... }
});

Configuration

Configure the plugin by specifying the following options in Copy to clipboardmedusa-config.ts:
  • Copy to clipboardeventBusName: Name of the AWS EventBridge bus to send events to.
  • Copy to clipboardregion: AWS region for the EventBridge.
  • Copy to clipboardaccessKeyId: AWS access key ID.
  • Copy to clipboardsecretAccessKey: AWS secret access key.

Usage

The plugin listens to Medusa events (e.g., order creation, product updates) and sends these events to the configured AWS EventBridge event bus. Events in EventBridge can then be used to trigger various AWS services such as Lambda, SNS, SQS, etc.

Example

{
"version": "0",
"id": "1281b54b-7930-44d1-2568-dd4f730b0ce2",
"detail-type": "LinkLocationFulfillmentProvider.attached",
"source": "my-event-bus",
"account": "211125766710",
"time": "2024-11-01T20:14:46Z",
"region": "us-east-1",
"resources": [],
"detail": {
"name": "LinkLocationFulfillmentProvider.attached",
"metadata": {
"source": "StockLocationStockLocationFulfillmentFulfillmentProviderLink",
"action": "attached",
"object": "LinkLocationFulfillmentProvider"
},
"data": {
"id": "locfp_01JBMNVE140Y1D9S01K90HHJS9"
}
}
}

Contributing

We welcome contributions from the community! If you encounter any issues or have suggestions for improvements, please feel free to open an issue or submit a pull request on our GitHub repository.

License

This library is licensed under the MIT License. See the LICENSE file for more details.

Build your own plugins

Develop your own plugins with our API to speed up your processes.

Make your plugin available via npm for it to be shared in our Plugin Library with the broader Medusa community.