From 13ea7a73484b82f5a8cec3ab6d2183c6eaf7faef Mon Sep 17 00:00:00 2001 From: Craig McNicholas Date: Thu, 27 Jul 2023 00:14:30 +0100 Subject: [PATCH] fix: #348 topic display name too long --- src/constructs/aws/Queue.ts | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/constructs/aws/Queue.ts b/src/constructs/aws/Queue.ts index 133e28db..e1dcdd39 100644 --- a/src/constructs/aws/Queue.ts +++ b/src/constructs/aws/Queue.ts @@ -232,9 +232,19 @@ export class Queue extends AwsConstruct { const alarmEmail = configuration.alarm; if (alarmEmail !== undefined) { + // generate the display name, AWS restriction is 100 chars + let displayName = `[Alert][${id}] failed jobs in dlq.`; + if (displayName.length > 100) { + // if the length is too long then try to pretty print + displayName = `[Alert][${id.substring( + 0, + id.length - (displayName.length - 100 - 3) + )}...] failed jobs in dlq.`; + } + const alarmTopic = new Topic(this, "AlarmTopic", { topicName: `${this.provider.stackName}-${id}-dlq-alarm-topic`, - displayName: `[Alert][${id}] There are failed jobs in the dead letter queue.`, + displayName, }); new Subscription(this, "AlarmTopicSubscription", { topic: alarmTopic,