apf-node-common 1.0.112 → 2.0.0

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "apf-node-common",
3
- "version": "1.0.112",
3
+ "version": "2.0.0",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -3,27 +3,36 @@ 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);
6
7
  AWS.config.update({ region: awsRegion });
7
8
  AuditLogger = require("../../auditlog/AuditLogger");
8
9
  var sns = new AWS.SNS({apiVersion: '2010-03-31'});
9
10
 
10
11
  module.exports = {
11
-
12
12
  async publish(topic, subject, message,messageAttributes) {
13
- var arn = '';
14
13
  try{
15
- const topicName = `${environment}-${topic}`;
16
-
17
- var response = await sns.createTopic({ Name: topicName }).promise();
18
- arn = response.TopicArn;
19
- const snsParameters = {
20
- Message: message,
21
- MessageAttributes:messageAttributes,
22
- Subject: subject,
23
- TopicArn: arn
24
- };
25
- log.info("Topic ARN is " + arn);
26
- var data = await sns.publish(snsParameters).promise();
14
+ let topicARN;
15
+ if(awsAccountNumber)
16
+ {
17
+ topicARN = `arn:aws:sns:${awsRegion}:${awsAccountNumber}:${environment}-${topic}`;
18
+ }
19
+ else
20
+ {
21
+ log.info("Calling CreateTopic" + topicARN);
22
+ const topicName = `${environment}-${topic}`;
23
+ var response = await sns.createTopic({ Name: topicName }).promise();
24
+ topicARN = response.TopicArn;
25
+ }
26
+ log.info("Topic ARN is " + topicARN);
27
+
28
+ const snsParameters = {
29
+ Message: message,
30
+ MessageAttributes:messageAttributes,
31
+ Subject: subject,
32
+ TopicArn: topicARN
33
+ };
34
+
35
+ var data = await sns.publish(snsParameters).promise();
27
36
 
28
37
  log.info("MessageID is " + data.MessageId);
29
38
  let auditLogger = new AuditLogger();