Skip to content

Commit

Permalink
adding paginations when listing rules
Browse files Browse the repository at this point in the history
  • Loading branch information
ljacobsson committed Aug 26, 2022
1 parent 25b4a87 commit 5503d72
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 16 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@mhlabs/evb-cli",
"version": "1.1.40",
"version": "1.1.41",
"description": "A package for building EventBridge/CloudWatch Events patterns",
"main": "index.js",
"scripts": {
Expand Down
31 changes: 16 additions & 15 deletions src/commands/shared/archive-util.js
Original file line number Diff line number Diff line change
Expand Up @@ -96,17 +96,12 @@ async function createAndExecute(
},
};
const accountId = ruleConfig.EventSourceArn.split(":")[4];
sfTarget.InputTransformer.InputTemplate = `{\"OriginalEvent\": <OriginalEvent>, "StartTime": "${
ruleConfig.EventStartTime
}", "TargetArn": "${
sfTarget.Arn
}", "Action": "dispatch", "ReplaySpeed": ${
cmd.replaySpeed || 0
}, "DispatchSource": "${
cmd.dispatchSourceOverride
}", "EventBusName": "${cmd.eventbus}", "ReplayName": "${
cmd.replayName
}"}`;
sfTarget.InputTransformer.InputTemplate = `{\"OriginalEvent\": <OriginalEvent>, "StartTime": "${ruleConfig.EventStartTime
}", "TargetArn": "${sfTarget.Arn
}", "Action": "dispatch", "ReplaySpeed": ${cmd.replaySpeed || 0
}, "DispatchSource": "${cmd.dispatchSourceOverride
}", "EventBusName": "${cmd.eventbus}", "ReplayName": "${cmd.replayName
}"}`;
sfTarget.Arn = `arn:aws:states:${AWS.config.region}:${accountId}:stateMachine:evb-cli-paced-replays`;
sfRule.Name = `${name}-sf`;
delete sfRule.Arn;
Expand Down Expand Up @@ -181,14 +176,20 @@ async function getDates() {
}

async function selectRules(eventbus, rulePrefix) {
const rules = await eventBridge
.listRules({ EventBusName: eventbus, NamePrefix: rulePrefix })
.promise();
const rules = [];
let token;
do {
const ruleResponse = await eventBridge
.listRules({ EventBusName: eventbus, NamePrefix: rulePrefix, NextToken: token })
.promise();
token = ruleResponse.NextToken;
rules.push(...ruleResponse.Rules);
} while (token)
let filteredRules;

do {
filteredRules = await inputUtil.multiSelectFrom(
rules.Rules.filter((p) => !p.ManagedBy).map((p) => {
rules.filter((p) => !p.ManagedBy).map((p) => {
return { name: p.Name, value: p };
}),
"Select rules to replay against",
Expand Down

0 comments on commit 5503d72

Please sign in to comment.