apf-node-common 1.0.110 → 1.0.111
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/utils/aws/AWSSNSUtils.js +13 -16
package/package.json
CHANGED
package/utils/aws/AWSSNSUtils.js
CHANGED
|
@@ -3,6 +3,7 @@ const AWS = require('aws-sdk');
|
|
|
3
3
|
|
|
4
4
|
const environment = (process.env.NODE_ENVIRONMENT || 'Test');
|
|
5
5
|
const awsRegion = (process.env.AWS_DEFAULT_REGION || 'us-east-2');
|
|
6
|
+
const awsAccountNumber = (process.env.AWS_ACCOUNT_NUMBER || '441138747230');
|
|
6
7
|
AWS.config.update({ region: awsRegion });
|
|
7
8
|
AuditLogger = require("../../auditlog/AuditLogger");
|
|
8
9
|
var sns = new AWS.SNS({apiVersion: '2010-03-31'});
|
|
@@ -10,20 +11,18 @@ var sns = new AWS.SNS({apiVersion: '2010-03-31'});
|
|
|
10
11
|
module.exports = {
|
|
11
12
|
|
|
12
13
|
async publish(topic, subject, message,messageAttributes) {
|
|
13
|
-
var arn = '';
|
|
14
14
|
try{
|
|
15
|
-
const
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
var data = await sns.publish(snsParameters).promise();
|
|
15
|
+
const topicARN = `arn:aws:sns:${awsRegion}:${awsAccountNumber}:${environment}-${topic}`;
|
|
16
|
+
log.info("Topic ARN is " + topicARN);
|
|
17
|
+
|
|
18
|
+
const snsParameters = {
|
|
19
|
+
Message: message,
|
|
20
|
+
MessageAttributes:messageAttributes,
|
|
21
|
+
Subject: subject,
|
|
22
|
+
TopicArn: topicARN
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
var data = await sns.publish(snsParameters).promise();
|
|
27
26
|
|
|
28
27
|
log.info("MessageID is " + data.MessageId);
|
|
29
28
|
let auditLogger = new AuditLogger();
|
|
@@ -31,8 +30,6 @@ module.exports = {
|
|
|
31
30
|
}catch(error){
|
|
32
31
|
log.error(`error occured while publishing event ${subject} to SNS `)
|
|
33
32
|
log.error(error, error.stack);
|
|
34
|
-
|
|
35
33
|
}
|
|
36
34
|
}
|
|
37
|
-
}
|
|
38
|
-
|
|
35
|
+
}
|