Skip to content

Commit

Permalink
Also remove the target before removing the rule
Browse files Browse the repository at this point in the history
  • Loading branch information
jakejscott committed Aug 17, 2021
1 parent 44a582e commit 8101da3
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/helpers/eventBridge.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ export default class EventBridge {
this.eventBridgeClient = new AWSClient.EventBridge();
this.eventBridgeName = eventBridgeName;
this.ruleName = `test-${eventBridgeName}-rule`;
this.targetId = "1";

const keepArg = process.argv.filter((x) => x.startsWith("--keep="))[0];
this.keep = keepArg ? keepArg.split("=")[1] : false;
Expand Down Expand Up @@ -45,7 +46,7 @@ export default class EventBridge {
Targets: [
{
Arn: sqsArn,
Id: "1",
Id: this.targetId,
},
],
})
Expand Down Expand Up @@ -142,11 +143,16 @@ export default class EventBridge {
})
.promise();

await this.eventBridgeClient.removeTargets({
Ids: [this.targetId],
Rule: this.ruleName,
EventBusName: this.eventBridgeName,
});

await this.eventBridgeClient
.deleteRule({
Name: this.ruleName,
EventBusName: this.eventBridgeName,
Force: true,
})
.promise();
} else {
Expand Down

0 comments on commit 8101da3

Please sign in to comment.