Skip to content

Commit 7a9872c

Browse files
committed
allow SNS subject configurable
1 parent cf24696 commit 7a9872c

File tree

3 files changed

+14
-0
lines changed

3 files changed

+14
-0
lines changed

.sprinkler.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,11 @@ cleanup:
3535
workflowActivationLock: "1h"
3636
workflowSchedulerLock: "1h"
3737

38+
# SNS notification configuration
39+
sns:
40+
# Subject for workflow failure notifications
41+
subject: "Workflow Schedule Failure"
42+
3843
# configs for static credentials or role arn to assume
3944
# aws:
4045
# clientRegion: "changeme"

common/config_keys.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,5 @@ const (
1111
DBConfigPassword = "db.password"
1212
DBConfigDBName = "db.dbname"
1313
DBConfigSSLMode = "db.sslmode"
14+
SNSConfigSubject = "sns.subject"
1415
)

service/scheduler.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import (
1313

1414
"github.com/aws/aws-sdk-go-v2/service/sns"
1515
"github.com/google/uuid"
16+
"github.com/spf13/viper"
1617
"gorm.io/gorm"
1718
"mce.salesforce.com/sprinkler/common"
1819
"mce.salesforce.com/sprinkler/database"
@@ -292,9 +293,16 @@ func notifyOwner(wf table.Workflow, orchardErr error) {
292293
log.Println("[error] error initiating SNS client")
293294
}
294295

296+
subject := viper.GetString(common.SNSConfigSubject)
297+
298+
if len(subject) > 100 {
299+
subject = subject[:100]
300+
}
301+
295302
croppedErrMsg := truncate(errMsg, SNSMessageMaxBytes)
296303
input := &sns.PublishInput{
297304
Message: &croppedErrMsg,
305+
Subject: &subject,
298306
TopicArn: wf.Owner,
299307
}
300308

0 commit comments

Comments
 (0)