-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathtemplate.yml
executable file
·545 lines (545 loc) · 20.3 KB
/
template.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
AWSTemplateFormatVersion: '2010-09-09'
Transform: AWS::Serverless-2016-10-31
Description: STARK infra for the parser and code generator
Parameters:
UserCICDPipelineBucketNameParameter:
Type: String
Description: Name for user bucket that will be used for the default STARK CI/CD pipeline.
UserCodeGenBucketNameParameter:
Type: String
Description: Name for user bucket that will hold static files and deployment packages created by STARK
UserWebsiteBucketNameParameter:
Type: String
Description: Name for user bucket that will be used as the website bucket for the STARK Parser UI. Not yet used in template, just needed for config.
TerraformArmSubscriptionId:
Type: String
Description: Credentials for Azure deployment through terraform
TerraformArmClientId:
Type: String
Description: Credentials for Azure deployment through terraform
TerraformArmClientSecret:
Type: String
Description: Credentials for Azure deployment through terraform
TerraformArmTenantId:
Type: String
Description: Credentials for Azure deployment through terraform
Resources:
STARKCloudFormationDeployServiceRole:
Type: AWS::IAM::Role
Properties:
AssumeRolePolicyDocument:
Version: '2012-10-17'
Statement:
-
Effect: Allow
Principal:
Service:
- 'cloudformation.amazonaws.com'
Action: 'sts:AssumeRole'
ManagedPolicyArns:
- 'arn:aws:iam::aws:policy/AdministratorAccess'
STARKParserApi:
Type: AWS::Serverless::HttpApi
Properties:
CorsConfiguration:
AllowOrigins:
- "*"
AllowHeaders:
- "*"
AllowMethods:
- "*"
MaxAge: 200
AllowCredentials: False
CFCustomResourceHelperLayer:
Type: AWS::Lambda::LayerVersion
Properties:
Content:
S3Bucket: !Ref UserCodeGenBucketNameParameter
S3Key: STARKLambdaLayers/CF_CustomResourceHelper_py39.zip
Description: Lambda-backed custom resource library for CloudFormation
LayerName: STARK_CF_CustomResourceHelper
CompatibleArchitectures:
- x86_64
- arm64
CompatibleRuntimes:
- python3.6
- python3.7
- python3.8
- python3.9
PyYamlLayer:
Type: AWS::Lambda::LayerVersion
Properties:
Content:
S3Bucket: !Ref UserCodeGenBucketNameParameter
S3Key: STARKLambdaLayers/yaml_py39.zip
Description: YAML module for Python 3.x
LayerName: STARK_PyYAML
CompatibleArchitectures:
- x86_64
- arm64
CompatibleRuntimes:
- python3.6
- python3.7
- python3.8
- python3.9
RequestslLayer:
Type: AWS::Lambda::LayerVersion
Properties:
Content:
S3Bucket: !Ref UserCodeGenBucketNameParameter
S3Key: STARKLambdaLayers/requests_py39.zip
Description: Requests module for Python 3.x
LayerName: STARK_Requests
CompatibleArchitectures:
- x86_64
- arm64
CompatibleRuntimes:
- python3.6
- python3.7
- python3.8
- python3.9
PymongoLayer:
Type: AWS::Lambda::LayerVersion
Properties:
Content:
S3Bucket: !Ref UserCodeGenBucketNameParameter
S3Key: STARKLambdaLayers/pymongo_py39.zip
Description: Pymongo module for Python 3.x
LayerName: STARK_Pymongo
CompatibleArchitectures:
- x86_64
- arm64
CompatibleRuntimes:
- python3.6
- python3.7
- python3.8
- python3.9
STARKFriendlyToSystemNamesLayer:
Type: AWS::Lambda::LayerVersion
Properties:
Content:
S3Bucket: !Ref UserCodeGenBucketNameParameter
S3Key: STARKLambdaLayers/STARK_friendly_to_system_name_py39.zip
Description: STARK module for converting user-supplied, human-friendly identifiers into system-friendly entity or variable names
LayerName: STARK_friendly_to_system_name
CompatibleArchitectures:
- x86_64
- arm64
CompatibleRuntimes:
- python3.6
- python3.7
- python3.8
- python3.9
STARKScryptLayer:
Type: AWS::Lambda::LayerVersion
Properties:
Content:
S3Bucket: !Ref UserCodeGenBucketNameParameter
S3Key: STARKLambdaLayers/STARK_scrypt_py39.zip
Description: STARK module for working with scrypt from the Python stdlib
LayerName: STARK_scrypt
CompatibleArchitectures:
- x86_64
- arm64
CompatibleRuntimes:
- python3.6
- python3.7
- python3.8
- python3.9
STARKGetRelationshipLayer:
Type: AWS::Lambda::LayerVersion
Properties:
Content:
S3Bucket: !Ref UserCodeGenBucketNameParameter
S3Key: STARKLambdaLayers/STARK_get_relationship_py39.zip
Description: STARK helper function for extracting relationship for 1-1 and 1-Many for business modules
LayerName: STARK_get_relationship
CompatibleArchitectures:
- x86_64
- arm64
CompatibleRuntimes:
- python3.6
- python3.7
- python3.8
- python3.9
STARKSuggestGraphicLayer:
Type: AWS::Lambda::LayerVersion
Properties:
Content:
S3Bucket: !Ref UserCodeGenBucketNameParameter
S3Key: STARKLambdaLayers/STARK_suggest_graphic_py39.zip
Description: STARK module for assigning suggested icons
LayerName: STARK_suggest_graphic
CompatibleArchitectures:
- x86_64
- arm64
CompatibleRuntimes:
- python3.6
- python3.7
- python3.8
- python3.9
STARKParserFunc:
Type: AWS::Serverless::Function
Properties:
Events:
ParserPostEvent:
Type: HttpApi
Properties:
Path: /parser
Method: POST
ApiId:
Ref: STARKParserApi
Runtime: python3.9
Handler: __init__.lambda_handler
CodeUri: lambda/STARK_Parser
Environment:
Variables:
STARK_ENVIRONMENT_TYPE: PROD
CODEGEN_BUCKET_NAME: !Ref UserCodeGenBucketNameParameter
Policies:
- AmazonS3FullAccess
- AWSLambda_FullAccess
Layers:
- !Ref PyYamlLayer
- !Ref STARKFriendlyToSystemNamesLayer
- !Ref STARKGetRelationshipLayer
- !Ref STARKScryptLayer
Timeout: 60
Architectures:
- arm64
STARKCFWriterFunc:
Type: AWS::Serverless::Function
Properties:
Runtime: python3.9
Handler: __init__.lambda_handler
CodeUri: lambda/STARK_CFWriter
Environment:
Variables:
STARK_ENVIRONMENT_TYPE: PROD
CODEGEN_BUCKET_NAME: !Ref UserCodeGenBucketNameParameter
Policies:
- AmazonS3FullAccess
- AWSLambdaBasicExecutionRole
Layers:
- !Ref PyYamlLayer
- !Ref STARKFriendlyToSystemNamesLayer
Timeout: 60
Architectures:
- arm64
STARKDeployFunc:
Type: AWS::Serverless::Function
Properties:
Events:
ParserPostEvent:
Type: HttpApi
Properties:
Path: /deploy
Method: POST
ApiId:
Ref: STARKParserApi
Runtime: python3.9
Handler: __init__.lambda_handler
CodeUri: lambda/STARK_Deploy
Environment:
Variables:
STARK_ENVIRONMENT_TYPE: PROD
CODEGEN_BUCKET_NAME: !Ref UserCodeGenBucketNameParameter
Policies:
- AWSLambda_FullAccess
- AWSCloudFormationFullAccess
- IAMFullAccess
- AmazonS3ReadOnlyAccess
Layers:
- !Ref PyYamlLayer
- !Ref STARKFriendlyToSystemNamesLayer
Timeout: 600
Architectures:
- arm64
STARKDeployCheckFunc:
Type: AWS::Serverless::Function
Properties:
Events:
ParserPostEvent:
Type: HttpApi
Properties:
Path: /deploy_check
Method: POST
ApiId:
Ref: STARKParserApi
Runtime: python3.9
Handler: __init__.lambda_handler
CodeUri: lambda/STARK_Deploy_Check
Environment:
Variables:
STARK_ENVIRONMENT_TYPE: PROD
CODEGEN_BUCKET_NAME: !Ref UserCodeGenBucketNameParameter
Policies:
- AWSLambda_FullAccess
- AWSCloudFormationFullAccess
- AmazonS3ReadOnlyAccess
- AWSCodeBuildAdminAccess
Layers:
- !Ref PyYamlLayer
- !Ref STARKFriendlyToSystemNamesLayer
Timeout: 600
Architectures:
- arm64
STARKCodeGenStaticWriter:
Type: AWS::Serverless::Function
Properties:
Runtime: python3.9
Handler: __init__.lambda_handler
CodeUri: lambda/STARK_CodeGen_Static
Environment:
Variables:
STARK_ENVIRONMENT_TYPE: PROD
CODEGEN_BUCKET_NAME: !Ref UserCodeGenBucketNameParameter
Policies:
- AmazonS3FullAccess
- AWSLambdaBasicExecutionRole
- AWSCodeCommitFullAccess
- AWSCodePipeline_FullAccess
- ReadOnlyAccess
- IAMFullAccess
Layers:
- !Ref CFCustomResourceHelperLayer
- !Ref PyYamlLayer
- !Ref STARKFriendlyToSystemNamesLayer
- !Ref STARKGetRelationshipLayer
Timeout: 60
Architectures:
- arm64
STARKCodeGenStaticWriterV2:
Type: AWS::Serverless::Function
Properties:
Runtime: python3.9
Handler: __init__.lambda_handler
CodeUri: lambda/STARK_CodeGen_StaticV2
Environment:
Variables:
STARK_ENVIRONMENT_TYPE: PROD
CODEGEN_BUCKET_NAME: !Ref UserCodeGenBucketNameParameter
Policies:
- AmazonS3FullAccess
- AWSLambdaBasicExecutionRole
- AWSCodeCommitFullAccess
- AWSCodePipeline_FullAccess
- ReadOnlyAccess
- IAMFullAccess
Layers:
- !Ref PyYamlLayer
- !Ref STARKFriendlyToSystemNamesLayer
- !Ref STARKGetRelationshipLayer
Timeout: 60
Architectures:
- arm64
STARKCodeGenDynamicWriter:
Type: AWS::Serverless::Function
Properties:
Runtime: python3.9
Handler: __init__.lambda_handler
CodeUri: lambda/STARK_CodeGen_Dynamic
Environment:
Variables:
STARK_ENVIRONMENT_TYPE: PROD
CODEGEN_BUCKET_NAME: !Ref UserCodeGenBucketNameParameter
Policies:
- AmazonS3FullAccess
- AWSLambda_FullAccess
- AWSCodeCommitFullAccess
- AWSCodePipeline_FullAccess
- IAMFullAccess
Layers:
- !Ref CFCustomResourceHelperLayer
- !Ref PyYamlLayer
- !Ref STARKFriendlyToSystemNamesLayer
- !Ref STARKGetRelationshipLayer
- !Ref STARKSuggestGraphicLayer
Timeout: 60
Architectures:
- arm64
STARKCodeGenDynamicWriterV2:
Type: AWS::Serverless::Function
Properties:
Runtime: python3.9
Handler: __init__.lambda_handler
CodeUri: lambda/STARK_CodeGen_DynamicV2
Environment:
Variables:
STARK_ENVIRONMENT_TYPE: PROD
CODEGEN_BUCKET_NAME: !Ref UserCodeGenBucketNameParameter
ARM_SUBSCRIPTION_ID: !Ref TerraformArmSubscriptionId
ARM_CLIENT_ID: !Ref TerraformArmClientId
ARM_CLIENT_SECRET: !Ref TerraformArmClientSecret
ARM_TENANT_ID: !Ref TerraformArmTenantId
Policies:
- AmazonS3FullAccess
- AWSLambda_FullAccess
- AWSCodeCommitFullAccess
- AWSCodePipeline_FullAccess
- IAMFullAccess
Layers:
- !Ref PyYamlLayer
- !Ref STARKFriendlyToSystemNamesLayer
- !Ref STARKGetRelationshipLayer
- !Ref STARKSuggestGraphicLayer
Timeout: 60
Architectures:
- arm64
STARKBucketCleanerFunc:
Type: AWS::Serverless::Function
Properties:
Runtime: python3.9
Handler: __init__.lambda_handler
CodeUri: lambda/STARK_WebsiteBucketCleaner
Environment:
Variables:
STARK_ENVIRONMENT_TYPE: PROD
Policies:
- AmazonS3FullAccess
- AWSLambdaBasicExecutionRole
Layers:
- !Ref CFCustomResourceHelperLayer
Timeout: 60
Architectures:
- arm64
STARKSystemBootstrap:
Type: AWS::Serverless::Function
Properties:
Runtime: python3.9
Handler: __init__.lambda_handler
CodeUri: lambda/STARK_SystemBootstrap
Environment:
Variables:
STARK_ENVIRONMENT_TYPE: PROD
CODEGEN_BUCKET_NAME: !Ref UserCodeGenBucketNameParameter
Policies:
- AmazonS3FullAccess
- AWSLambdaBasicExecutionRole
- AWSCodeCommitFullAccess
Layers:
- !Ref CFCustomResourceHelperLayer
- !Ref PyYamlLayer
- !Ref STARKFriendlyToSystemNamesLayer
Timeout: 60
Architectures:
- arm64
STARKSystemPreLaunch:
Type: AWS::Serverless::Function
Properties:
Runtime: python3.9
Handler: __init__.lambda_handler
CodeUri: lambda/STARK_SystemPreLaunch
Environment:
Variables:
STARK_ENVIRONMENT_TYPE: PROD
CODEGEN_BUCKET_NAME: !Ref UserCodeGenBucketNameParameter
Policies:
- AWSLambdaBasicExecutionRole
- AWSCodeCommitFullAccess
- AmazonDynamoDBFullAccess
- AmazonS3FullAccess
Layers:
- !Ref CFCustomResourceHelperLayer
- !Ref PyYamlLayer
- !Ref STARKFriendlyToSystemNamesLayer
- !Ref STARKSuggestGraphicLayer
- !Ref STARKGetRelationshipLayer
Architectures:
- arm64
MemorySize: 1760
Timeout: 60
STARKSystemPreLaunchV2:
Type: AWS::Serverless::Function
Properties:
Runtime: python3.9
Handler: __init__.lambda_handler
CodeUri: lambda/STARK_SystemPreLaunchV2
Environment:
Variables:
STARK_ENVIRONMENT_TYPE: PROD
CODEGEN_BUCKET_NAME: !Ref UserCodeGenBucketNameParameter
Policies:
- AWSLambdaBasicExecutionRole
- AWSCodeCommitFullAccess
- AmazonDynamoDBFullAccess
- AmazonS3FullAccess
Layers:
- !Ref PyYamlLayer
- !Ref STARKFriendlyToSystemNamesLayer
- !Ref STARKSuggestGraphicLayer
- !Ref STARKGetRelationshipLayer
- !Ref PymongoLayer
Architectures:
- arm64
MemorySize: 1760
Timeout: 60
STARKWebsiteUpdaterFunc:
Type: AWS::Serverless::Function
Properties:
Runtime: python3.9
Handler: __init__.lambda_handler
CodeUri: lambda/STARK_WebsiteUpdater
Environment:
Variables:
STARK_ENVIRONMENT_TYPE: PROD
CODEGEN_BUCKET_NAME: !Ref UserCodeGenBucketNameParameter
WEBSITE_BUCKET_NAME: !Ref UserWebsiteBucketNameParameter
API_GATEWAY_ID: !Ref STARKParserApi
Policies:
- AmazonS3FullAccess
- AWSLambdaBasicExecutionRole
- ReadOnlyAccess
Layers:
- !Ref CFCustomResourceHelperLayer
Timeout: 60
Architectures:
- arm64
STARKWebsiteUpdaterRun:
Type: AWS::CloudFormation::CustomResource
Properties:
ServiceToken: !GetAtt STARKWebsiteUpdaterFunc.Arn
ApiGatewayId: !Ref STARKParserApi
UpdateToken: RandomTokenFromBuildScript
Remarks: This will update STARK_settings.js with the appropriate API Gateway ID
DependsOn:
- STARKParserApi
- STARKWebsiteUpdaterFunc
STARKConfigWriterFunc:
Type: AWS::Serverless::Function
Properties:
Runtime: python3.9
Handler: __init__.lambda_handler
CodeUri: lambda/STARK_ConfigWriter
Environment:
Variables:
STARK_ENVIRONMENT_TYPE: PROD
CODEGEN_BUCKET_NAME: !Ref UserCodeGenBucketNameParameter
CICD_BUCKET_NAME: !Ref UserCICDPipelineBucketNameParameter
API_GATEWAY_ID: !Ref STARKParserApi
CLEANER_ARN: !GetAtt STARKBucketCleanerFunc.Arn
CF_WRITER_ARN: !GetAtt STARKCFWriterFunc.Arn
CG_DYNAMIC_ARN: !GetAtt STARKCodeGenDynamicWriter.Arn
CG_DYNAMICV2_ARN: !GetAtt STARKCodeGenDynamicWriterV2.Arn
CG_STATIC_ARN: !GetAtt STARKCodeGenStaticWriter.Arn
CG_STATICV2_ARN: !GetAtt STARKCodeGenStaticWriterV2.Arn
CF_DEPLOY_ROLE_ARN: !GetAtt STARKCloudFormationDeployServiceRole.Arn
SYSTEM_BOOTSTRAP_ARN: !GetAtt STARKSystemBootstrap.Arn
SYSTEM_PRELAUNCH_ARN: !GetAtt STARKSystemPreLaunch.Arn
SYSTEM_PRELAUNCHV2_ARN: !GetAtt STARKSystemPreLaunchV2.Arn
Policies:
- AmazonS3FullAccess
- AWSLambdaBasicExecutionRole
Layers:
- !Ref CFCustomResourceHelperLayer
Timeout: 60
Architectures:
- arm64
STARKConfigWriterRun:
Type: AWS::CloudFormation::CustomResource
Properties:
ServiceToken: !GetAtt STARKConfigWriterFunc.Arn
UpdateToken: RandomTokenFromBuildScript
Remarks: This will update STARK_settings.js with the appropriate API Gateway ID
DependsOn:
- STARKConfigWriterFunc