From 2c5661f38996250de759d6bb22129fa9536aa457 Mon Sep 17 00:00:00 2001 From: Scott Guymer Date: Fri, 28 Apr 2023 16:36:35 +0200 Subject: [PATCH] Allow endpoint to be configured for sqs event publisher Signed-off-by: Scott Guymer --- .changeset/cold-laws-turn.md | 5 +++++ .../src/publisher/AwsSqsConsumingEventPublisher.ts | 6 +++++- .../events-backend-module-aws-sqs/src/publisher/config.ts | 1 + 3 files changed, 11 insertions(+), 1 deletion(-) create mode 100644 .changeset/cold-laws-turn.md diff --git a/.changeset/cold-laws-turn.md b/.changeset/cold-laws-turn.md new file mode 100644 index 0000000000..6220f088db --- /dev/null +++ b/.changeset/cold-laws-turn.md @@ -0,0 +1,5 @@ +--- +'@backstage/plugin-events-backend-module-aws-sqs': minor +--- + +Allow endpoint configuration for sqs, enabling use of localstack for testing. diff --git a/plugins/events-backend-module-aws-sqs/src/publisher/AwsSqsConsumingEventPublisher.ts b/plugins/events-backend-module-aws-sqs/src/publisher/AwsSqsConsumingEventPublisher.ts index e649e2ee83..4f4e6ea55d 100644 --- a/plugins/events-backend-module-aws-sqs/src/publisher/AwsSqsConsumingEventPublisher.ts +++ b/plugins/events-backend-module-aws-sqs/src/publisher/AwsSqsConsumingEventPublisher.ts @@ -68,7 +68,11 @@ export class AwsSqsConsumingEventPublisher implements EventPublisher { VisibilityTimeout: config.visibilityTimeout?.as('seconds'), WaitTimeSeconds: config.pollingWaitTime.as('seconds'), }; - this.sqs = new SQSClient({ region: config.region }); + + this.sqs = new SQSClient({ + region: config.region, + endpoint: config.endpoint, + }); this.queueUrl = config.queueUrl; this.taskTimeoutSeconds = config.timeout.as('seconds'); diff --git a/plugins/events-backend-module-aws-sqs/src/publisher/config.ts b/plugins/events-backend-module-aws-sqs/src/publisher/config.ts index c6b74ea8d3..47cd82857c 100644 --- a/plugins/events-backend-module-aws-sqs/src/publisher/config.ts +++ b/plugins/events-backend-module-aws-sqs/src/publisher/config.ts @@ -31,6 +31,7 @@ export interface AwsSqsEventSourceConfig { topic: string; visibilityTimeout?: Duration; waitTimeAfterEmptyReceive: Duration; + endpoint?: string; } // TODO(pjungermann): validation could be improved similar to `convertToHumanDuration` at @backstage/backend-tasks