@izara_project/izara-core-library-sns 1.0.4 → 1.0.6
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/index.js +3 -1
- package/package.json +1 -1
- package/src/SnsSharedLib.js +29 -0
package/index.js
CHANGED
|
@@ -24,5 +24,7 @@ const SnsSharedLib = require('./src/SnsSharedLib');
|
|
|
24
24
|
module.exports = {
|
|
25
25
|
snsTopicName: SnsSharedLib.snsTopicName,
|
|
26
26
|
snsTopicArn: SnsSharedLib.snsTopicArn,
|
|
27
|
-
extractTopicName: SnsSharedLib.extractTopicName
|
|
27
|
+
extractTopicName: SnsSharedLib.extractTopicName,
|
|
28
|
+
snsTopicNameByFlowSchema: SnsSharedLib.snsTopicNameByFlowSchema,
|
|
29
|
+
snsTopicArnByFlowSchema: SnsSharedLib.snsTopicArnByFlowSchema
|
|
28
30
|
};
|
package/package.json
CHANGED
package/src/SnsSharedLib.js
CHANGED
|
@@ -63,3 +63,32 @@ module.exports.extractTopicName = (topicArn) => {
|
|
|
63
63
|
let topicName = topicArn.split(":")[5];
|
|
64
64
|
return topicName
|
|
65
65
|
}
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* Generate sns topic name for Flowschema
|
|
69
|
+
* @param {Object} _izContext
|
|
70
|
+
* @param {string} topicName
|
|
71
|
+
* @param {string} serviceTag
|
|
72
|
+
*/
|
|
73
|
+
module.exports.snsTopicNameByFlowSchema = (_izContext, topicName, serviceTag = null) => {
|
|
74
|
+
if (!serviceTag) { // for owner service
|
|
75
|
+
return process.env.iz_serviceTag + "_" + process.env.iz_stage + "_" + topicName;
|
|
76
|
+
} else { // create table name for external service
|
|
77
|
+
return serviceTag + "_" + process.env.iz_stage + "_" + topicName;
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
/**
|
|
82
|
+
* Generate sns topic name
|
|
83
|
+
* @param {Object} _izContext
|
|
84
|
+
* @param {string} topicName
|
|
85
|
+
* @param {string} serviceTag
|
|
86
|
+
*
|
|
87
|
+
* @returns {string} deployed SNS resource name
|
|
88
|
+
*/
|
|
89
|
+
module.exports.snsTopicArnByFlowSchema = async (_izContext, topicName, serviceTag = null) => {
|
|
90
|
+
const snsTopicArn = await this.snsTopicNameByFlowSchema(_izContext, topicName, serviceTag)
|
|
91
|
+
// concatenate with env stage setting
|
|
92
|
+
// arn:aws:sns:us-east-1:468568093265:GraphHandlerDevInChangeRelationshipType
|
|
93
|
+
return await `arn:aws:sns:${process.env.iz_region}:${process.env.iz_accountId}:${snsTopicArn}`
|
|
94
|
+
}
|