@izara_project/izara-core-generate-service-code 1.0.67 → 1.0.68
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/.prettierrc +11 -0
- package/package.json +16 -12
- package/scripts/format-ejs.js +105 -0
- package/src/compile/compileProject.js +16 -1
- package/src/compile/loadSchemas.js +89 -4
- package/src/emit/crud/emitDynamicCrudFlowSchemas.js +1 -2
- package/src/emit/crud/templates/CreateEndpoint_Main.ejs +296 -105
- package/src/emit/crud/templates/DeleteEndpoint_Main.ejs +222 -144
- package/src/emit/crud/templates/FlowEndpointBeforeLogical_Main.ejs +22 -6
- package/src/emit/crud/templates/FlowEndpointComplete_Main.ejs +134 -43
- package/src/emit/crud/templates/FlowEndpoint_HdrWbs.ejs +51 -31
- package/src/emit/crud/templates/FlowHandler_HdrApi.ejs +53 -45
- package/src/emit/crud/templates/FlowHandler_HdrInv.ejs +28 -26
- package/src/emit/crud/templates/FlowHandler_HdrSqs.ejs +15 -11
- package/src/emit/crud/templates/FlowMain_Wbs.ejs +53 -38
- package/src/emit/crud/templates/GetEndpoint_Main.ejs +5 -2
- package/src/emit/crud/templates/GetRangeEndpoint_Main.ejs +2 -2
- package/src/emit/crud/templates/UpdateEndpoint_Main.ejs +402 -249
- package/src/emit/custom/customFlows.js +51 -21
- package/src/emit/custom/emitCustomFlowApplicationArtifacts.js +13 -18
- package/src/emit/custom/templates/FlowEndpoint_Main.ejs +48 -36
- package/src/emit/custom/templates/FlowStep_Main.ejs +7 -9
- package/src/emit/custom/templates/s3/ConfirmReserved_HdrSqs.ejs +59 -54
- package/src/emit/custom/templates/s3/ConfirmReserved_Main.ejs +33 -23
- package/src/emit/custom/templates/s3/CreateObject_HdrWbs.ejs +30 -23
- package/src/emit/custom/templates/s3/CreateObject_Main.ejs +56 -39
- package/src/emit/custom/templates/s3/CreatePreSignUrl_HdrSqs.ejs +56 -51
- package/src/emit/custom/templates/s3/CreatePreSignUrl_Main.ejs +112 -75
- package/src/emit/custom/templates/s3/FlowHandler_HdrS3.ejs +12 -7
- package/src/emit/custom/templates/s3/ProcessS3File_Main.ejs +11 -8
- package/src/emit/custom/templates/s3/ReservedLimit_HdrSqs.ejs +64 -55
- package/src/emit/custom/templates/s3/ReservedLimit_Main.ejs +74 -52
- package/src/emit/custom/templates/triggerCache/CheckTriggerCache_HdrSqs.ejs +58 -14
- package/src/emit/custom/templates/triggerCache/CheckTriggerCache_Main.ejs +12 -17
- package/src/emit/custom/templates/triggerCache/TriggerCacheComplete_Main.ejs +20 -13
- package/src/emit/custom/templates/triggerCache/TriggerCache_Main.ejs +4 -1
- package/src/emit/function/functionYamlArtifact.js +20 -0
- package/src/emit/rbac/emitDynamicRbacFlowSchemas.js +28 -15
- package/src/emit/rbac/emitRbacApplicationArtifacts.js +168 -69
- package/src/emit/rbac/templates/CreateTargetRole_HdrSqs.ejs +41 -18
- package/src/emit/rbac/templates/CreateTargetRole_Main.ejs +23 -3
- package/src/emit/rbac/templates/ListRbac_HdrApi.ejs +27 -5
- package/src/emit/rbac/templates/ListRbac_HdrSqs.ejs +41 -8
- package/src/emit/rbac/templates/ListRbac_Main.ejs +26 -6
- package/src/emit/rbac/templates/RbacMutation_Main.ejs +23 -3
- package/src/emit/rbac/templates/UserRbacFlow_HdrSqs.ejs +46 -0
- package/src/emit/rbac/templates/UserRbacFlow_Main.ejs +152 -33
- package/src/emit/rbac/templates/UserRoleMutation_Main.ejs +24 -4
- package/src/emit/relationship/emitDynamicRelationshipFlowSchemas.js +1 -2
- package/src/emit/relationship/templates/ChangeRelationshipComplete_Main.ejs +64 -37
- package/src/emit/relationship/templates/ChangeRelationship_Main.ejs +258 -142
- package/src/emit/relationship/templates/CreateRelationshipComplete_Main.ejs +68 -43
- package/src/emit/relationship/templates/CreateRelationship_Main.ejs +315 -171
- package/src/emit/relationship/templates/DeleteRelationshipComplete_Main.ejs +67 -41
- package/src/emit/relationship/templates/DeleteRelationship_Main.ejs +226 -115
- package/src/emit/relationship/templates/FlowHandler_HdrApi.ejs +41 -33
- package/src/emit/relationship/templates/FlowHandler_HdrDsq.ejs +15 -11
- package/src/emit/relationship/templates/FlowHandler_HdrInv.ejs +28 -26
- package/src/emit/relationship/templates/FlowHandler_HdrSqs.ejs +15 -11
- package/src/emit/relationship/templates/GetRelationshipComplete_Main.ejs +46 -26
- package/src/emit/relationship/templates/GetRelationship_Main.ejs +233 -126
- package/src/emit/relationship/templates/MoveRelationshipComplete_Main.ejs +72 -44
- package/src/emit/relationship/templates/MoveRelationship_Main.ejs +266 -150
- package/src/emit/relationship/templates/UpdateRelationshipComplete_Main.ejs +74 -45
- package/src/emit/relationship/templates/UpdateRelationship_Main.ejs +285 -152
- package/src/emit/resource/emitResourceArtifacts.js +107 -11
- package/src/emit/resource/templates/DynamoDBTable_Yaml.ejs +18 -18
- package/src/emit/resource/templates/FlowOut_Yaml.ejs +5 -5
- package/src/emit/resource/templates/GeneratedLambdaRoleServiceConfig.ejs +138 -0
- package/src/emit/resource/templates/ResourceBeforeLogicalYaml.ejs +44 -44
- package/src/emit/resource/templates/ResourceSqsYaml.ejs +36 -36
- package/src/emit/resource/templates/ResourceYaml.ejs +48 -48
- package/src/emit/resource/templates/S3Bucket_Yaml.ejs +19 -0
- package/src/emit/resource/templates/SharedResource_Yaml.ejs +11 -11
- package/src/emit/resource/templates/SystemDynamoDB_Yaml.ejs +105 -105
- package/src/generate.js +6 -2
- package/test/createTargetRoleHandler.test.js +63 -14
- package/test/customFlowApplicationArtifacts.test.js +48 -23
- package/test/dynamicCrudFlowSchemas.test.js +6 -6
- package/test/dynamicRbacFlowSchemas.test.js +8 -12
- package/test/dynamicRelationshipFlowSchemas.test.js +3 -3
- package/test/publicApi.test.js +10 -12
- package/test/resourceArtifacts.test.js +12 -2
- package/docs/test.png +0 -0
- package/src/emit/rbac/templates/UserRbacFlow_HdrInv.ejs +0 -10
- /package/docs/{test.mmd → TriggeredCacheFlow.mmd} +0 -0
|
@@ -13,6 +13,7 @@ import { hasSystemWebSocket } from '../system/emitSystemWebSocketArtifacts.js';
|
|
|
13
13
|
const TEMPLATE_URL = new URL('./templates/', import.meta.url);
|
|
14
14
|
const RESOURCE_ROOT = 'resource/sls_yaml/generatedCode/source';
|
|
15
15
|
const APP_ROOT = 'app/sls_yaml/generatedCode/source';
|
|
16
|
+
const INITIAL_SETUP_ROOT = 'app/initial_setup/generatedCode/source';
|
|
16
17
|
const CRUD_ACTIONS = ['Create', 'Update', 'Delete', 'Get'];
|
|
17
18
|
const RELATIONSHIP_ACTIONS = [
|
|
18
19
|
'CreateRelationship',
|
|
@@ -83,11 +84,13 @@ export async function emitResourceArtifacts({
|
|
|
83
84
|
throw new TypeError('objects, relationships, and flows must be arrays');
|
|
84
85
|
}
|
|
85
86
|
const state = createResourceState({ objects, relationships, flows });
|
|
86
|
-
const [inSqs, out, dynamo, iam] = await Promise.all([
|
|
87
|
+
const [inSqs, out, dynamo, iam, lambdaRoleConfig, s3] = await Promise.all([
|
|
87
88
|
renderInSqs(state),
|
|
88
89
|
renderOut(state),
|
|
89
90
|
renderDynamo(state),
|
|
90
|
-
renderIam(state)
|
|
91
|
+
renderIam(state),
|
|
92
|
+
renderLambdaRoleConfig(state),
|
|
93
|
+
renderS3(state)
|
|
91
94
|
]);
|
|
92
95
|
return [
|
|
93
96
|
{
|
|
@@ -102,9 +105,17 @@ export async function emitResourceArtifacts({
|
|
|
102
105
|
path: `${RESOURCE_ROOT}/generated-dynamoDB-table.yml`,
|
|
103
106
|
content: normalizeYaml(dynamo)
|
|
104
107
|
},
|
|
108
|
+
{
|
|
109
|
+
path: `${RESOURCE_ROOT}/generated-s3.yml`,
|
|
110
|
+
content: normalizeYaml(s3)
|
|
111
|
+
},
|
|
105
112
|
{
|
|
106
113
|
path: `${APP_ROOT}/generate-shared-resource.yml`,
|
|
107
114
|
content: normalizeYaml(iam)
|
|
115
|
+
},
|
|
116
|
+
{
|
|
117
|
+
path: `${INITIAL_SETUP_ROOT}/generatedLambdaRoleServiceConfig.js`,
|
|
118
|
+
content: lambdaRoleConfig
|
|
108
119
|
}
|
|
109
120
|
];
|
|
110
121
|
}
|
|
@@ -113,7 +124,9 @@ export const resourceArtifactPaths = [
|
|
|
113
124
|
`${RESOURCE_ROOT}/generated-sns-in-sqs.yml`,
|
|
114
125
|
`${RESOURCE_ROOT}/generated-sns-out.yml`,
|
|
115
126
|
`${RESOURCE_ROOT}/generated-dynamoDB-table.yml`,
|
|
116
|
-
`${
|
|
127
|
+
`${RESOURCE_ROOT}/generated-s3.yml`,
|
|
128
|
+
`${APP_ROOT}/generate-shared-resource.yml`,
|
|
129
|
+
`${INITIAL_SETUP_ROOT}/generatedLambdaRoleServiceConfig.js`
|
|
117
130
|
];
|
|
118
131
|
|
|
119
132
|
function createResourceState({ objects, relationships, flows }) {
|
|
@@ -169,9 +182,10 @@ function createResourceState({ objects, relationships, flows }) {
|
|
|
169
182
|
});
|
|
170
183
|
objects
|
|
171
184
|
.filter(hasRbacAddOn)
|
|
172
|
-
.forEach(object =>
|
|
173
|
-
|
|
174
|
-
|
|
185
|
+
.forEach(object => {
|
|
186
|
+
const flowTag = upperFirst(object.objectType) + 'RbacFlow';
|
|
187
|
+
ownTopics.add(flowTag);
|
|
188
|
+
});
|
|
175
189
|
}
|
|
176
190
|
const beforeLogicalByAction = new Map();
|
|
177
191
|
for (const flow of flows.filter(
|
|
@@ -197,9 +211,7 @@ function createResourceState({ objects, relationships, flows }) {
|
|
|
197
211
|
...flowExtTopicSteps(flows).map(({ flow }) =>
|
|
198
212
|
customFlowRoleName(flow.flowTag)
|
|
199
213
|
),
|
|
200
|
-
...flowDsqSteps(flows).map(({ flow }) =>
|
|
201
|
-
customFlowRoleName(flow.flowTag)
|
|
202
|
-
)
|
|
214
|
+
...flowDsqSteps(flows).map(({ flow }) => customFlowRoleName(flow.flowTag))
|
|
203
215
|
])
|
|
204
216
|
];
|
|
205
217
|
const websocket = hasSystemWebSocket(flows, {
|
|
@@ -227,6 +239,13 @@ function createResourceState({ objects, relationships, flows }) {
|
|
|
227
239
|
...collectTables(objects),
|
|
228
240
|
...collectTables(relationships)
|
|
229
241
|
]);
|
|
242
|
+
const externalDynamoTables = objects.flatMap(
|
|
243
|
+
object => object.externalDynamoResources ?? []
|
|
244
|
+
);
|
|
245
|
+
const s3Buckets = flows
|
|
246
|
+
.filter(flow => includesEvent(flow, 's3') && flow.createBucket === true)
|
|
247
|
+
.map(flow => flow.bucketName)
|
|
248
|
+
.filter(Boolean);
|
|
230
249
|
return {
|
|
231
250
|
crud,
|
|
232
251
|
rbac,
|
|
@@ -243,7 +262,11 @@ function createResourceState({ objects, relationships, flows }) {
|
|
|
243
262
|
.filter(
|
|
244
263
|
topic =>
|
|
245
264
|
flows.some(
|
|
246
|
-
flow =>
|
|
265
|
+
flow =>
|
|
266
|
+
(flow?.outputTopic ||
|
|
267
|
+
(includesEvent(flow, 'ownTopic') &&
|
|
268
|
+
flow.initiateBy === 'user')) &&
|
|
269
|
+
upperFirst(flow.flowTag) === topic
|
|
247
270
|
) ||
|
|
248
271
|
(relationships.length > 0 &&
|
|
249
272
|
topic !== 'GetRelationship' &&
|
|
@@ -259,6 +282,7 @@ function createResourceState({ objects, relationships, flows }) {
|
|
|
259
282
|
allTableNames: [...new Set([...SYSTEM_TABLES, ...tableMap.keys()])].sort(),
|
|
260
283
|
objectTableNames,
|
|
261
284
|
relationshipTableNames,
|
|
285
|
+
externalDynamoTables,
|
|
262
286
|
objectTablesByType: new Map(
|
|
263
287
|
objects
|
|
264
288
|
.map(object => [
|
|
@@ -269,10 +293,20 @@ function createResourceState({ objects, relationships, flows }) {
|
|
|
269
293
|
])
|
|
270
294
|
.filter(([, tableName]) => tableName)
|
|
271
295
|
),
|
|
296
|
+
s3Buckets,
|
|
272
297
|
flows
|
|
273
298
|
};
|
|
274
299
|
}
|
|
275
300
|
|
|
301
|
+
async function renderS3(state) {
|
|
302
|
+
if (state.s3Buckets.length === 0) return 'Resources:';
|
|
303
|
+
const template = await readFile(new URL('S3Bucket_Yaml.ejs', TEMPLATE_URL), 'utf8');
|
|
304
|
+
const chunks = await Promise.all(
|
|
305
|
+
state.s3Buckets.map(bucketName => ejs.render(template, { bucketName }))
|
|
306
|
+
);
|
|
307
|
+
return `Resources:\n${chunks.join('\n')}`;
|
|
308
|
+
}
|
|
309
|
+
|
|
276
310
|
async function renderInSqs(state) {
|
|
277
311
|
const chunks = await Promise.all([
|
|
278
312
|
...state.ownTopics.map(queueName =>
|
|
@@ -328,6 +362,19 @@ async function renderIam(state) {
|
|
|
328
362
|
});
|
|
329
363
|
}
|
|
330
364
|
|
|
365
|
+
async function renderLambdaRoleConfig(state) {
|
|
366
|
+
const s3Flows = state.flows
|
|
367
|
+
.filter(flow => includesEvent(flow, 's3'))
|
|
368
|
+
.map(flow => ({
|
|
369
|
+
roleName: upperFirst(flow.flowTag)
|
|
370
|
+
}));
|
|
371
|
+
return render('GeneratedLambdaRoleServiceConfig.ejs', {
|
|
372
|
+
crud: state.crud,
|
|
373
|
+
relationships: state.relationships,
|
|
374
|
+
s3Flows
|
|
375
|
+
});
|
|
376
|
+
}
|
|
377
|
+
|
|
331
378
|
function roleStatements(state, roleName) {
|
|
332
379
|
const statements = [];
|
|
333
380
|
if (roleNeedsSchemaRead(state, roleName)) {
|
|
@@ -341,7 +388,10 @@ function roleStatements(state, roleName) {
|
|
|
341
388
|
addStatement(
|
|
342
389
|
statements,
|
|
343
390
|
dynamoActionsForRole(roleName),
|
|
344
|
-
|
|
391
|
+
[
|
|
392
|
+
...dynamoArns(roleTableNames(state, roleName)),
|
|
393
|
+
...externalDynamoArns(roleExternalDynamoTables(state, roleName))
|
|
394
|
+
]
|
|
345
395
|
);
|
|
346
396
|
addStatement(
|
|
347
397
|
statements,
|
|
@@ -501,6 +551,52 @@ function dynamoArns(tableNames) {
|
|
|
501
551
|
);
|
|
502
552
|
}
|
|
503
553
|
|
|
554
|
+
/**
|
|
555
|
+
* Generates DynamoDB ARNs for tables that belong to a parent service
|
|
556
|
+
* (via extendObjType). Uses the parent serviceTag instead of the
|
|
557
|
+
* current service's resourcePrefix, because those tables are owned
|
|
558
|
+
* by a different CloudFormation stack.
|
|
559
|
+
*
|
|
560
|
+
* ARN format:
|
|
561
|
+
* ...table/{parentServiceTag}_{iz_stage}_{tableName}
|
|
562
|
+
*/
|
|
563
|
+
function externalDynamoArns(externalTables) {
|
|
564
|
+
const seen = new Set();
|
|
565
|
+
const unique = [];
|
|
566
|
+
for (const table of externalTables) {
|
|
567
|
+
const dedupeKey = `${table.serviceTag}::${table.tableName}`;
|
|
568
|
+
if (!seen.has(dedupeKey)) {
|
|
569
|
+
seen.add(dedupeKey);
|
|
570
|
+
unique.push(table);
|
|
571
|
+
}
|
|
572
|
+
}
|
|
573
|
+
return unique
|
|
574
|
+
.sort((a, b) =>
|
|
575
|
+
`${a.serviceTag}_${a.tableName}`.localeCompare(
|
|
576
|
+
`${b.serviceTag}_${b.tableName}`
|
|
577
|
+
)
|
|
578
|
+
)
|
|
579
|
+
.map(
|
|
580
|
+
({ serviceTag, tableName }) =>
|
|
581
|
+
`arn:aws:dynamodb:${'${self:custom.iz_region}'}:${'${self:custom.iz_accountId}'}:table/${serviceTag}${'${self:custom.iz_stage}'}${tableName}`
|
|
582
|
+
);
|
|
583
|
+
}
|
|
584
|
+
|
|
585
|
+
/**
|
|
586
|
+
* Returns the external DynamoDB table references (cross-service)
|
|
587
|
+
* that should be accessible from a given IAM role.
|
|
588
|
+
*/
|
|
589
|
+
function roleExternalDynamoTables(state, roleName) {
|
|
590
|
+
if (
|
|
591
|
+
roleName === 'FlowObjectsRole' ||
|
|
592
|
+
roleName === 'FlowRelationshipRole' ||
|
|
593
|
+
roleName === 'ProcFindDataRole'
|
|
594
|
+
) {
|
|
595
|
+
return state.externalDynamoTables;
|
|
596
|
+
}
|
|
597
|
+
return [];
|
|
598
|
+
}
|
|
599
|
+
|
|
504
600
|
function queueArns(queueNames) {
|
|
505
601
|
return [...new Set(queueNames)]
|
|
506
602
|
.sort()
|
|
@@ -1,20 +1,20 @@
|
|
|
1
1
|
##===== [DynamoDB Table: <%- tableName %>]
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
<% if (sk) { %>
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
<% } %>
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
<% if (sk) { %>
|
|
18
|
-
|
|
19
|
-
|
|
2
|
+
<%- tableName %>Table:
|
|
3
|
+
Type: AWS::DynamoDB::Table
|
|
4
|
+
Properties:
|
|
5
|
+
TableName: ${self:custom.iz_resourcePrefix}<%- tableName %>
|
|
6
|
+
BillingMode: PAY_PER_REQUEST
|
|
7
|
+
AttributeDefinitions:
|
|
8
|
+
- AttributeName: '<%- pk %>'
|
|
9
|
+
AttributeType: 'S'
|
|
10
|
+
<% if (sk) { %>
|
|
11
|
+
- AttributeName: '<%- sk %>'
|
|
12
|
+
AttributeType: 'S'
|
|
13
|
+
<% } %>
|
|
14
|
+
KeySchema:
|
|
15
|
+
- AttributeName: '<%- pk %>'
|
|
16
|
+
KeyType: 'HASH'
|
|
17
|
+
<% if (sk) { %>
|
|
18
|
+
- AttributeName: '<%- sk %>'
|
|
19
|
+
KeyType: 'RANGE'
|
|
20
20
|
<% } %>
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
##===== [Topic Out]
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
2
|
+
Out<%- topicName %>:
|
|
3
|
+
Type: AWS::SNS::Topic
|
|
4
|
+
Properties:
|
|
5
|
+
DisplayName: 'SNS Message out'
|
|
6
|
+
TopicName: ${self:custom.iz_serviceTag}_${self:custom.iz_stage}_<%- topicName %>_Out
|
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
/*
|
|
2
|
+
Copyright (C) 2020 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
|
+
import Logger from '@izara_project/izara-core-library-logger';
|
|
19
|
+
import dynamodbSharedLib from '@izara_project/izara-core-library-dynamodb';
|
|
20
|
+
import lambdaSharedLib from '@izara_project/izara-core-library-lambda';
|
|
21
|
+
import snsSharedLib from '@izara_project/izara-core-library-sns';
|
|
22
|
+
import initialSetupConfig from '../../config/Config.js';
|
|
23
|
+
|
|
24
|
+
const _izContext = { logger: Logger };
|
|
25
|
+
|
|
26
|
+
export function generatedLambdaRole() {
|
|
27
|
+
const externalLambdaRole = [
|
|
28
|
+
<% if (crud) { -%>
|
|
29
|
+
{
|
|
30
|
+
roleName: 'FlowObjects',
|
|
31
|
+
statement: [
|
|
32
|
+
{
|
|
33
|
+
Sid: 'FlowObjectsRoleTest0',
|
|
34
|
+
Effect: 'Allow',
|
|
35
|
+
Action: ['lambda:InvokeFunction'],
|
|
36
|
+
Resource: [
|
|
37
|
+
`arn:aws:lambda:${process.env.iz_region}:${process.env.iz_accountId}:function:${lambdaSharedLib.lambdaFunctionName(_izContext, 'GetNodeHdrInv', 'GraphHandler')}`
|
|
38
|
+
]
|
|
39
|
+
},
|
|
40
|
+
|
|
41
|
+
{
|
|
42
|
+
Sid: 'FlowObjectsRoleTest1',
|
|
43
|
+
Effect: 'Allow',
|
|
44
|
+
Action: ['sns:Publish'],
|
|
45
|
+
Resource: [
|
|
46
|
+
`arn:aws:sns:${process.env.iz_region}:${process.env.iz_accountId}:${snsSharedLib.snsTopicNameByFlowSchema(_izContext, 'UpdateNode_In', 'GraphHandler')}`
|
|
47
|
+
]
|
|
48
|
+
},
|
|
49
|
+
|
|
50
|
+
{
|
|
51
|
+
Sid: 'FlowObjectsRoleTest2',
|
|
52
|
+
Effect: 'Allow',
|
|
53
|
+
Action: ['sns:Publish'],
|
|
54
|
+
Resource: [
|
|
55
|
+
`arn:aws:sns:${process.env.iz_region}:${process.env.iz_accountId}:${snsSharedLib.snsTopicNameByFlowSchema(_izContext, 'CreateNode_In', 'GraphHandler')}`
|
|
56
|
+
]
|
|
57
|
+
}
|
|
58
|
+
//(<createFlowObjectsRole>)
|
|
59
|
+
//(</createFlowObjectsRole>)
|
|
60
|
+
]
|
|
61
|
+
},
|
|
62
|
+
<% } -%>
|
|
63
|
+
|
|
64
|
+
{
|
|
65
|
+
roleName: 'ProcFindData',
|
|
66
|
+
statement: [
|
|
67
|
+
{
|
|
68
|
+
Sid: 'ProcFindDataRoleTest0',
|
|
69
|
+
Effect: 'Allow',
|
|
70
|
+
Action: ['lambda:InvokeFunction'],
|
|
71
|
+
Resource: [
|
|
72
|
+
`arn:aws:lambda:${process.env.iz_region}:${process.env.iz_accountId}:function:${lambdaSharedLib.lambdaFunctionName(_izContext, 'GetNodeHdrInv', 'GraphHandler')}`
|
|
73
|
+
]
|
|
74
|
+
}
|
|
75
|
+
//(<createProcFindDataRole>)
|
|
76
|
+
//(</createProcFindDataRole>)
|
|
77
|
+
]
|
|
78
|
+
} <% if (relationships) { %>,
|
|
79
|
+
|
|
80
|
+
{
|
|
81
|
+
roleName: 'FlowRelationship',
|
|
82
|
+
statement: [
|
|
83
|
+
{
|
|
84
|
+
Sid: 'FlowRelationshipRoleTest0',
|
|
85
|
+
Effect: 'Allow',
|
|
86
|
+
Action: ['lambda:InvokeFunction'],
|
|
87
|
+
Resource: [
|
|
88
|
+
`arn:aws:lambda:${process.env.iz_region}:${process.env.iz_accountId}:function:${lambdaSharedLib.lambdaFunctionName(_izContext, 'GetRelationshipHdrInv', 'GraphHandler')}`
|
|
89
|
+
]
|
|
90
|
+
},
|
|
91
|
+
|
|
92
|
+
{
|
|
93
|
+
Sid: 'FlowRelationshipRoleTest1',
|
|
94
|
+
Effect: 'Allow',
|
|
95
|
+
Action: ['sns:Publish'],
|
|
96
|
+
Resource: [
|
|
97
|
+
`arn:aws:sns:${process.env.iz_region}:${process.env.iz_accountId}:${snsSharedLib.snsTopicNameByFlowSchema(_izContext, 'CreateRelationship_In', 'GraphHandler')}`,
|
|
98
|
+
`arn:aws:sns:${process.env.iz_region}:${process.env.iz_accountId}:${snsSharedLib.snsTopicNameByFlowSchema(_izContext, 'UpdateRelationship_In', 'GraphHandler')}`,
|
|
99
|
+
`arn:aws:sns:${process.env.iz_region}:${process.env.iz_accountId}:${snsSharedLib.snsTopicNameByFlowSchema(_izContext, 'DeleteRelationship_In', 'GraphHandler')}`,
|
|
100
|
+
`arn:aws:sns:${process.env.iz_region}:${process.env.iz_accountId}:${snsSharedLib.snsTopicNameByFlowSchema(_izContext, 'ChangeRelationship_In', 'GraphHandler')}`,
|
|
101
|
+
`arn:aws:sns:${process.env.iz_region}:${process.env.iz_accountId}:${snsSharedLib.snsTopicNameByFlowSchema(_izContext, 'MoveRelationship_In', 'GraphHandler')}`
|
|
102
|
+
]
|
|
103
|
+
}
|
|
104
|
+
//(<createFlowRelationshipRole>)
|
|
105
|
+
//(</createFlowRelationshipRole>)
|
|
106
|
+
]
|
|
107
|
+
} <% } -%>,
|
|
108
|
+
|
|
109
|
+
<% s3Flows.forEach(function(flow) { -%> {
|
|
110
|
+
roleName: '<%= flow.roleName %>',
|
|
111
|
+
statement: [
|
|
112
|
+
{
|
|
113
|
+
Sid: '<%= flow.roleName %>RoleTest0',
|
|
114
|
+
Effect: 'Allow',
|
|
115
|
+
Action: ['sns:Publish'],
|
|
116
|
+
Resource: [
|
|
117
|
+
`arn:aws:sns:${process.env.iz_region}:${process.env.iz_accountId}:${snsSharedLib.snsTopicNameByFlowSchema(_izContext, 'ReservedDynamicUsage_In', 'AccountLimits')}`
|
|
118
|
+
]
|
|
119
|
+
},
|
|
120
|
+
|
|
121
|
+
{
|
|
122
|
+
Sid: '<%= flow.roleName %>RoleTest1',
|
|
123
|
+
Effect: 'Allow',
|
|
124
|
+
Action: ['sns:Publish'],
|
|
125
|
+
Resource: [
|
|
126
|
+
`arn:aws:sns:${process.env.iz_region}:${process.env.iz_accountId}:${snsSharedLib.snsTopicNameByFlowSchema(_izContext, 'ConfirmDynamicAfterUpload_In', 'AccountLimits')}`
|
|
127
|
+
]
|
|
128
|
+
}
|
|
129
|
+
//(<create<%= flow.roleName %>Role>)
|
|
130
|
+
//(</create<%= flow.roleName %>Role>)
|
|
131
|
+
]
|
|
132
|
+
} <% }); %>
|
|
133
|
+
//(<additionalRole>)
|
|
134
|
+
//(</additionalRole>)
|
|
135
|
+
];
|
|
136
|
+
|
|
137
|
+
return externalLambdaRole;
|
|
138
|
+
}
|
|
@@ -1,47 +1,47 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
1
|
+
<%_ flowTags.forEach(flowTag => { _%>
|
|
2
|
+
SubscriptionOut<%- flowTag.charAt(0).toUpperCase() + flowTag.slice(1) %>To<%- queueName %>:
|
|
3
|
+
Type: AWS::SNS::Subscription
|
|
4
|
+
Properties:
|
|
5
|
+
TopicArn: !Ref Out<%- flowTag.charAt(0).toUpperCase() + flowTag.slice(1) %>
|
|
6
|
+
Endpoint: 'arn:aws:sqs:${self:custom.iz_region}:${self:custom.iz_accountId}:${self:custom.iz_resourcePrefix}<%- queueName %>HdrSqs'
|
|
7
|
+
Protocol: 'sqs'
|
|
8
|
+
<%_ }) _%>
|
|
9
|
+
##===== [Queue]
|
|
10
|
+
<%- queueName %>HdrSqs:
|
|
11
|
+
Type: 'AWS::SQS::Queue'
|
|
12
|
+
Properties:
|
|
13
|
+
QueueName: ${self:custom.iz_resourcePrefix}<%- queueName %>HdrSqs
|
|
14
|
+
RedrivePolicy:
|
|
15
|
+
deadLetterTargetArn:
|
|
16
|
+
Fn::GetAtt:
|
|
17
|
+
- <%- queueName %>HdrSqsDLQ
|
|
18
|
+
- Arn
|
|
19
|
+
maxReceiveCount: 3
|
|
20
|
+
VisibilityTimeout: 120
|
|
21
21
|
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
22
|
+
##===== [Queue DLQ]
|
|
23
|
+
<%- queueName %>HdrSqsDLQ:
|
|
24
|
+
Type: AWS::SQS::Queue
|
|
25
|
+
Properties:
|
|
26
|
+
QueueName: ${self:custom.iz_resourcePrefix}<%- queueName %>HdrSqsDLQ
|
|
27
27
|
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
28
|
+
##===== [Queue Policy]
|
|
29
|
+
<%- queueName %>HdrSqsPolicy:
|
|
30
|
+
Type: AWS::SQS::QueuePolicy
|
|
31
|
+
Properties:
|
|
32
|
+
PolicyDocument:
|
|
33
|
+
Version: '2012-10-17'
|
|
34
|
+
Statement:
|
|
35
|
+
- Sid: 'allow-sns-messages'
|
|
36
|
+
Effect: Allow
|
|
37
|
+
Principal: '*'
|
|
38
|
+
Resource:
|
|
39
|
+
Fn::GetAtt:
|
|
40
|
+
- <%- queueName %>HdrSqs
|
|
41
|
+
- Arn
|
|
42
|
+
Action: 'SQS:SendMessage'
|
|
43
|
+
Queues:
|
|
44
|
+
- Ref: <%- queueName %>HdrSqs
|
|
45
45
|
|
|
46
|
-
|
|
47
|
-
|
|
46
|
+
#<#<%- queueName %>QueueSetting#>
|
|
47
|
+
#<#/<%- queueName %>QueueSetting#>
|
|
@@ -1,39 +1,39 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
1
|
+
##===== [Queue]
|
|
2
|
+
<%- resourceQueueName || queueName %>:
|
|
3
|
+
Type: 'AWS::SQS::Queue'
|
|
4
|
+
Properties:
|
|
5
|
+
QueueName: ${self:custom.iz_resourcePrefix}<%- queueName %>
|
|
6
|
+
RedrivePolicy:
|
|
7
|
+
deadLetterTargetArn:
|
|
8
|
+
Fn::GetAtt:
|
|
9
|
+
- <%- resourceQueueName || queueName %>DLQ
|
|
10
|
+
- Arn
|
|
11
|
+
maxReceiveCount: 3
|
|
12
|
+
VisibilityTimeout: 120
|
|
13
13
|
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
14
|
+
##===== [Queue DLQ]
|
|
15
|
+
<%- resourceQueueName || queueName %>DLQ:
|
|
16
|
+
Type: AWS::SQS::Queue
|
|
17
|
+
Properties:
|
|
18
|
+
QueueName: ${self:custom.iz_resourcePrefix}<%- queueName %>DLQ
|
|
19
19
|
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
20
|
+
##===== [Queue Policy]
|
|
21
|
+
<%- resourceQueueName || queueName %>Policy:
|
|
22
|
+
Type: AWS::SQS::QueuePolicy
|
|
23
|
+
Properties:
|
|
24
|
+
PolicyDocument:
|
|
25
|
+
Version: '2012-10-17'
|
|
26
|
+
Statement:
|
|
27
|
+
- Sid: 'allow-sns-messages'
|
|
28
|
+
Effect: Allow
|
|
29
|
+
Principal: '*'
|
|
30
|
+
Resource:
|
|
31
|
+
Fn::GetAtt:
|
|
32
|
+
- <%- resourceQueueName || queueName %>
|
|
33
|
+
- Arn
|
|
34
|
+
Action: 'SQS:SendMessage'
|
|
35
|
+
Queues:
|
|
36
|
+
- Ref: <%- resourceQueueName || queueName %>
|
|
37
37
|
|
|
38
|
-
|
|
39
|
-
|
|
38
|
+
#<#<%- queueName %>QueueSetting#>
|
|
39
|
+
#<#/<%- queueName %>QueueSetting#>
|