@izara_project/izara-core-library-sns 1.0.1 → 1.0.2
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 +28 -0
- package/package.json +3 -13
- package/src/SnsSharedLib.js +65 -0
package/index.js
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/*
|
|
2
|
+
Copyright (C) 2021 Sven Mason <http://izara.io>
|
|
3
|
+
|
|
4
|
+
This program is free software: you can redistribute it and/or modify
|
|
5
|
+
it under the terms of the GNU Affero General Public License as
|
|
6
|
+
published by the Free Software Foundation, either version 3 of the
|
|
7
|
+
License, or (at your option) any later version.
|
|
8
|
+
|
|
9
|
+
This program is distributed in the hope that it will be useful,
|
|
10
|
+
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
11
|
+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
12
|
+
GNU Affero General Public License for more details.
|
|
13
|
+
|
|
14
|
+
You should have received a copy of the GNU Affero General Public License
|
|
15
|
+
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
'use strict';
|
|
19
|
+
|
|
20
|
+
// Import the SnS shared library functions
|
|
21
|
+
const SnsSharedLib = require('./src/SnsSharedLib');
|
|
22
|
+
|
|
23
|
+
// Export all the functions
|
|
24
|
+
module.exports = {
|
|
25
|
+
snsTopicName: SnsSharedLib.snsTopicName,
|
|
26
|
+
snsTopicArn: SnsSharedLib.snsTopicArn,
|
|
27
|
+
extractTopicName: SnsSharedLib.extractTopicName
|
|
28
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@izara_project/izara-core-library-sns",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.2",
|
|
4
4
|
"description": "Connecting with AWS SNS Resource",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -20,16 +20,6 @@
|
|
|
20
20
|
"testEnvironment": "node"
|
|
21
21
|
},
|
|
22
22
|
"dependencies": {
|
|
23
|
-
"@
|
|
24
|
-
"@aws-sdk/client-s3": "^3.731.1",
|
|
25
|
-
"@aws-sdk/crc64-nvme-crt": "^3.731.0",
|
|
26
|
-
"@izara_project/izara-core-library-core": "^1.0.14",
|
|
27
|
-
"@izara_project/izara-core-library-external-request": "^1.0.17",
|
|
28
|
-
"@izara_project/izara-core-library-logger": "^1.0.6",
|
|
29
|
-
"@izara_project/izara-shared": "^1.0.109",
|
|
30
|
-
"glob": "^11.0.0",
|
|
31
|
-
"lodash": "^4.17.21",
|
|
32
|
-
"object-hash": "^3.0.0",
|
|
33
|
-
"read-yaml-file": "^2.1.0"
|
|
23
|
+
"@izara_project/izara-core-library-service-schemas": "^1.0.39"
|
|
34
24
|
}
|
|
35
|
-
}
|
|
25
|
+
}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
/*
|
|
2
|
+
Copyright (C) 2021 Sven Mason <http://izara.io>
|
|
3
|
+
|
|
4
|
+
This program is free software: you can redistribute it and/or modify
|
|
5
|
+
it under the terms of the GNU Affero General Public License as
|
|
6
|
+
published by the Free Software Foundation, either version 3 of the
|
|
7
|
+
License, or (at your option) any later version.
|
|
8
|
+
|
|
9
|
+
This program is distributed in the hope that it will be useful,
|
|
10
|
+
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
11
|
+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
12
|
+
GNU Affero General Public License for more details.
|
|
13
|
+
|
|
14
|
+
You should have received a copy of the GNU Affero General Public License
|
|
15
|
+
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
'use strict';
|
|
19
|
+
|
|
20
|
+
const { getServiceNameWithCache } = require('@izara_project/izara-core-library-service-schemas/src/ServiceConfig')
|
|
21
|
+
/**
|
|
22
|
+
* Generate sns topic name
|
|
23
|
+
* @param {Object} _izContext
|
|
24
|
+
* @param {string} topicName
|
|
25
|
+
* @param {string} serviceTag
|
|
26
|
+
*
|
|
27
|
+
* @returns {string} deployed SNS resource name
|
|
28
|
+
*/
|
|
29
|
+
module.exports.snsTopicName = async (_izContext, topicName, serviceTag = null) => {
|
|
30
|
+
// concatenate with env stage setting
|
|
31
|
+
// return serviceName + process.env.iz_stage + topicName
|
|
32
|
+
|
|
33
|
+
if (!serviceTag) { // for owner service
|
|
34
|
+
return process.env.iz_resourcePrefix + topicName;
|
|
35
|
+
} else { // create table name for external service
|
|
36
|
+
return await getServiceNameWithCache(_izContext, serviceTag) + process.env.iz_stage + topicName;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* Generate sns topic name
|
|
43
|
+
* @param {Object} _izContext
|
|
44
|
+
* @param {string} topicName
|
|
45
|
+
* @param {string} serviceTag
|
|
46
|
+
*
|
|
47
|
+
* @returns {string} deployed SNS resource name
|
|
48
|
+
*/
|
|
49
|
+
module.exports.snsTopicArn = async (_izContext, topicName, serviceTag = null) => {
|
|
50
|
+
const snsTopicArn = await this.snsTopicName(_izContext, topicName, serviceTag)
|
|
51
|
+
// concatenate with env stage setting
|
|
52
|
+
// arn:aws:sns:us-east-1:468568093265:GraphHandlerDevInChangeRelationshipType
|
|
53
|
+
return await `arn:aws:sns:${process.env.iz_region}:${process.env.iz_accountId}:${snsTopicArn}`
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* Generate sns topic name
|
|
58
|
+
* @param {string} topicArn
|
|
59
|
+
*
|
|
60
|
+
* @returns {string} deployed SNS resource name
|
|
61
|
+
*/
|
|
62
|
+
module.exports.extractTopicName = (topicArn) => {
|
|
63
|
+
let topicName = topicArn.split(":")[5];
|
|
64
|
+
return topicName
|
|
65
|
+
}
|