Skip to content

Commit

Permalink
Merge pull request #21 from c4e/feature/allow-receive-custom-eventbus
Browse files Browse the repository at this point in the history
move eventBusName to the send compiler
  • Loading branch information
c4e authored Oct 30, 2020
2 parents 72a250f + 8ea9eed commit eaee6ee
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 5 deletions.
7 changes: 4 additions & 3 deletions lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ class ServerlessPlugin {
}

compileReceiver() {
const { organizationId, statementId, eventBusName } = this.eventBridgeCrossOrganization.receiveEvents;
const { organizationId, statementId } = this.eventBridgeCrossOrganization.receiveEvents;
const alphaNumericStatementId = statementId.replace(/[^a-z0-9+]+/gi, '');

const template = {
Expand All @@ -46,7 +46,7 @@ class ServerlessPlugin {
"Properties": {
"Action": "events:PutEvents",
"Principal": "*",
"EventBusName": eventBusName || "default",
"EventBusName": "default",
"StatementId": alphaNumericStatementId,
"Condition": {
"Type": "StringEquals",
Expand Down Expand Up @@ -114,6 +114,7 @@ class ServerlessPlugin {
compileRulesToEventBridge() {
const targetAccounts = this.eventBridgeCrossOrganization.sendEvents;
const rulesTemplate = targetAccounts.map(account => {
const eventBusName = account.eventBusName;
const ruleName = account.ruleName || `EventRuleCase${account.targetAccountId}`;
const alphaNumericRuleName = ruleName.replace(/[^a-z0-9+]+/gi, '');

Expand All @@ -122,7 +123,7 @@ class ServerlessPlugin {
"Type" : "AWS::Events::Rule",
"Properties" : {
"Name" : alphaNumericRuleName,
"EventBusName" : "default",
"EventBusName" : eventBusName || "default",
"EventPattern" : account.pattern,
"State" : "ENABLED",
"Targets" : [
Expand Down
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "serverless-events-cross-organization",
"version": "v1.0.12-beta",
"version": "v1.0.13-beta",
"description": "Add roles, rules, policies to send and receive events cross organization",
"main": "lib/index.js",
"scripts": {
Expand Down

0 comments on commit eaee6ee

Please sign in to comment.