Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 17 additions & 6 deletions src/helpers/eventBridge.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
/* eslint-disable max-lines */
import { AWSError, EventBridge as AWSEventBridge, SQS } from "aws-sdk";
import {
ConfigurationOptions as AWSConfig,
AWSError,
EventBridge as AWSEventBridge,
SQS,
} from "aws-sdk";
import { PromiseResult } from "aws-sdk/lib/request";
import { AWSClient, region } from "./general";
import { removeUndefinedMessages } from "./utils/removeUndefinedMessages";
Expand All @@ -13,15 +18,18 @@ export default class EventBridge {
sqsClient: SQS | undefined;
targetId: string | undefined;

async init(eventBridgeName: string): Promise<void> {
this.eventBridgeClient = new AWSClient.EventBridge();
async init(
eventBridgeName: string,
awsClientConfig?: AWSConfig
): Promise<void> {
this.eventBridgeClient = new AWSClient.EventBridge(awsClientConfig);
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] === "true" : false;
this.sqsClient = new AWSClient.SQS();
this.sqsClient = new AWSClient.SQS(awsClientConfig);
if (!this.keep) {
console.info(
"If running repeatedly add '--keep=true' to keep testing resources up to avoid creation throttles"
Expand Down Expand Up @@ -91,9 +99,12 @@ export default class EventBridge {
.promise();
}

static async build(eventBridgeName: string): Promise<EventBridge> {
static async build(
eventBridgeName: string,
awsClientConfig?: AWSConfig
): Promise<EventBridge> {
const eventBridge = new EventBridge();
await eventBridge.init(eventBridgeName);
await eventBridge.init(eventBridgeName, awsClientConfig);

return eventBridge;
}
Expand Down
13 changes: 8 additions & 5 deletions src/helpers/stepFunctions.ts
Original file line number Diff line number Diff line change
@@ -1,19 +1,22 @@
import { StepFunctions as AWSStepFunctions } from "aws-sdk";
import {
ConfigurationOptions as AWSConfig,
StepFunctions as AWSStepFunctions,
} from "aws-sdk";

export default class StepFunctions {
stepFunctions: AWSStepFunctions | undefined;
allStateMachines: AWSStepFunctions.ListStateMachinesOutput | undefined;

async init(): Promise<void> {
this.stepFunctions = new AWSStepFunctions();
async init(awsClientConfig?: AWSConfig): Promise<void> {
this.stepFunctions = new AWSStepFunctions(awsClientConfig);
this.allStateMachines = await this.stepFunctions
.listStateMachines()
.promise();
}

static async build(): Promise<StepFunctions> {
static async build(awsClientConfig?: AWSConfig): Promise<StepFunctions> {
const stepFunction = new StepFunctions();
await stepFunction.init();
await stepFunction.init(awsClientConfig);

return stepFunction;
}
Expand Down