Skip to content

Commit 33ee9dd

Browse files
committed
feat: add support for custom SQS endpoint
1 parent cd800f2 commit 33ee9dd

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

src/api/integrations/event/sqs/sqs.controller.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,8 @@ export class SqsController extends EventController implements EventControllerInt
2828
accessKeyId: awsConfig.ACCESS_KEY_ID,
2929
secretAccessKey: awsConfig.SECRET_ACCESS_KEY,
3030
},
31-
3231
region: awsConfig.REGION,
32+
endpoint: awsConfig.ENDPOINT || undefined,
3333
});
3434

3535
this.logger.info('SQS initialized');
@@ -126,7 +126,9 @@ export class SqsController extends EventController implements EventControllerInt
126126
? 'singlequeue'
127127
: `${event.replace('.', '_').toLowerCase()}`;
128128
const queueName = `${prefixName}_${eventFormatted}.fifo`;
129-
const sqsUrl = `https://sqs.${sqsConfig.REGION}.amazonaws.com/${sqsConfig.ACCOUNT_ID}/${queueName}`;
129+
const sqsUrl = sqsConfig.ENDPOINT
130+
? `${sqsConfig.ENDPOINT.replace(/\/$/, '')}/${sqsConfig.ACCOUNT_ID}/${queueName}`
131+
: `https://sqs.${sqsConfig.REGION}.amazonaws.com/${sqsConfig.ACCOUNT_ID}/${queueName}`;
130132

131133
const message = {
132134
...(extra ?? {}),

src/config/env.config.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,7 @@ export type Sqs = {
121121
SECRET_ACCESS_KEY: string;
122122
ACCOUNT_ID: string;
123123
REGION: string;
124+
ENDPOINT: string;
124125
MAX_PAYLOAD_SIZE: number;
125126
EVENTS: {
126127
APPLICATION_STARTUP: boolean;
@@ -585,6 +586,7 @@ export class ConfigService {
585586
SECRET_ACCESS_KEY: process.env.SQS_SECRET_ACCESS_KEY || '',
586587
ACCOUNT_ID: process.env.SQS_ACCOUNT_ID || '',
587588
REGION: process.env.SQS_REGION || '',
589+
ENDPOINT: process.env.SQS_ENDPOINT || '',
588590
MAX_PAYLOAD_SIZE: Number.parseInt(process.env.SQS_MAX_PAYLOAD_SIZE ?? '1048576'),
589591
EVENTS: {
590592
APPLICATION_STARTUP: process.env?.SQS_GLOBAL_APPLICATION_STARTUP === 'true',

0 commit comments

Comments
 (0)