Switch to unified view

a b/source/GenomicsAnalysisCode/omics_cfn.yml
1
AWSTemplateFormatVersion: 2010-09-09
2
3
Description: Omics Resources
4
Parameters:
5
  OmicsResourcePrefix:
6
    Type: String
7
    Default: omics-cfn
8
  OmicsResourcesS3Bucket:
9
    Type: String
10
  OmicsDataS3Bucket:
11
    Type: String
12
  OmicsReferenceS3Key:
13
    Type: String
14
    Default: references/hg38/Homo_sapiens_assembly38.fasta
15
  OmicsReferenceName:
16
    Type: String
17
    Default: hg38
18
  ClinvarS3Key:
19
    Type: String
20
    Default: annotation/vcf/clinvar/clinvar.vcf.gz
21
  SampleVcfS3Key:
22
    Type: String
23
    Default: variants/vcf/variants.vcf.gz
24
  OneKgVcfS3Key:
25
    Type: String
26
    Default: variants/1kg/ALL.chr22.shapeit2_integrated_snvindels_v2a_27022019.GRCh38.phased.filtNA.vcf.gz
27
  OmicsAnnotationStoreName:
28
    Type: String
29
    Default: omicsannotationstore
30
  OmicsVariantStoreName:
31
    Type: String
32
    Default: omicsvariantstore
33
  AnnotationStoreFormat:
34
    Type: String
35
    Default: 'VCF'
36
37
Resources:
38
39
# OMICS CREATE REFERENCE STORE
40
  OmicsReferenceStore:
41
    Type: Custom::OmicsReferenceStore
42
    DependsOn:
43
      - OmicsReferenceStoreLambda
44
    Version: 1.0
45
    Properties:
46
      ServiceToken: !Sub ${OmicsReferenceStoreLambda.Arn}
47
      ReferenceStoreName: !Sub ${OmicsResourcePrefix}-reference-store
48
  
49
  OmicsReferenceStoreLambda:
50
    Type: AWS::Lambda::Function
51
    DependsOn:
52
      - OmicsReferenceStoreLambdaRole
53
    Properties:
54
      Handler: create_reference_store_lambda.handler
55
      Runtime: python3.9
56
      FunctionName: !Sub ${OmicsResourcePrefix}-create-reference-store
57
      Code:
58
        S3Bucket: !Sub ${OmicsResourcesS3Bucket}
59
        S3Key: artifacts/create_reference_store_lambda.zip
60
      Role: !Sub ${OmicsReferenceStoreLambdaRole.Arn}
61
      Timeout: 60
62
  
63
  OmicsReferenceStoreLambdaRole:
64
    Type: AWS::IAM::Role
65
    Properties:
66
      AssumeRolePolicyDocument:
67
        Version: 2012-10-17
68
        Statement:
69
          - Action:
70
              - sts:AssumeRole
71
            Effect: Allow
72
            Principal:
73
              Service:
74
                - lambda.amazonaws.com
75
      Path: /
76
      Policies:
77
        - PolicyName: CreateReferenceStorePolicy
78
          PolicyDocument:
79
            Statement:
80
              - Effect: Allow
81
                Action:
82
                  - logs:CreateLogGroup
83
                  - logs:CreateLogStream
84
                  - logs:PutLogEvents
85
                Resource:
86
                  - !Sub arn:aws:logs:${AWS::Region}:${AWS::AccountId}:log-group:/aws/lambda/*
87
              - Effect: Allow
88
                Action: 
89
                  - omics:*
90
                Resource: '*'
91
              - Effect: Allow
92
                Action:
93
                  - lambda:AddPermission
94
                  - lambda:RemovePermission
95
                  - events:PutRule
96
                  - events:DeleteRule
97
                  - events:PutTargets
98
                  - events:RemoveTargets
99
                Resource: '*'
100
  
101
  # OMICS IMPORT REFERENCE
102
  OmicsImportReference:
103
    Type: Custom::OmicsImportReference
104
    DependsOn:
105
      - OmicsReferenceStore
106
      - OmicsImportReferenceLambda
107
    Version: 1.0
108
    Properties:
109
      ServiceToken: !Sub ${OmicsImportReferenceLambda.Arn}
110
      ReferenceStoreId: !Sub ${OmicsReferenceStore.ReferenceStoreId}
111
      ReferenceName: !Sub ${OmicsReferenceName}
112
      OmicsImportReferenceRoleArn: !Sub ${OmicsImportReferenceJobRole.Arn}
113
      ReferenceSourceS3Uri: !Sub s3://${OmicsDataS3Bucket}/${OmicsReferenceS3Key}
114
  
115
  OmicsImportReferenceLambda:
116
    Type: AWS::Lambda::Function
117
    DependsOn:
118
      - OmicsImportReferenceLambdaRole
119
      - OmicsImportReferenceJobRole
120
    Properties:
121
      Handler: import_reference_lambda.handler
122
      Runtime: python3.9
123
      FunctionName: !Sub ${OmicsResourcePrefix}-import-reference
124
      Code:
125
        S3Bucket: !Sub ${OmicsResourcesS3Bucket}
126
        S3Key: artifacts/import_reference_lambda.zip
127
      Role: !Sub ${OmicsImportReferenceLambdaRole.Arn}
128
      Timeout: 60
129
  
130
  OmicsImportReferenceLambdaRole:
131
    Type: AWS::IAM::Role
132
    DependsOn:
133
      - OmicsImportReferenceJobRole
134
    Properties:
135
      AssumeRolePolicyDocument:
136
        Version: 2012-10-17
137
        Statement:
138
          - Action:
139
              - sts:AssumeRole
140
            Effect: Allow
141
            Principal:
142
              Service:
143
                - lambda.amazonaws.com
144
      Path: /
145
      Policies:
146
        - PolicyName: ImportReferencePolicy
147
          PolicyDocument:
148
            Statement:
149
              - Effect: Allow
150
                Action:
151
                  - logs:CreateLogGroup
152
                  - logs:CreateLogStream
153
                  - logs:PutLogEvents
154
                Resource:
155
                  - !Sub arn:aws:logs:${AWS::Region}:${AWS::AccountId}:log-group:/aws/lambda/*
156
              - Effect: Allow
157
                Action: 
158
                  - omics:*
159
                Resource: '*'
160
              - Effect: Allow
161
                Action:
162
                  - lambda:AddPermission
163
                  - lambda:RemovePermission
164
                  - events:PutRule
165
                  - events:DeleteRule
166
                  - events:PutTargets
167
                  - events:RemoveTargets
168
                Resource: '*'
169
              - Effect: Allow
170
                Action:
171
                  - iam:GetRole
172
                  - iam:PassRole
173
                Resource: !Sub ${OmicsImportReferenceJobRole.Arn}
174
175
  OmicsImportReferenceJobRole:
176
    Type: AWS::IAM::Role
177
    Properties:
178
      AssumeRolePolicyDocument:
179
        Version: 2012-10-17
180
        Statement:
181
          - Action:
182
              - sts:AssumeRole
183
            Effect: Allow
184
            Principal:
185
              Service:
186
                - omics.amazonaws.com
187
      Path: /
188
      Policies:
189
        - PolicyName: ImportReferenceJobRolePolicy
190
          PolicyDocument:
191
            Statement:
192
              - Effect: Allow
193
                Action:
194
                  - s3:GetObject
195
                  - s3:GetBucketLocation
196
                  - s3:ListBucket
197
                Resource:
198
                  - !Sub arn:aws:s3:::${OmicsDataS3Bucket}
199
                  - !Sub arn:aws:s3:::${OmicsDataS3Bucket}/${OmicsReferenceS3Key}
200
              
201
  # OMICS CREATE VARIANT STORE
202
  OmicsVariantStore:
203
    Type: Custom::OmicsVariantStore
204
    DependsOn:
205
      - OmicsVariantStoreLambda
206
      - OmicsImportReference
207
    Version: 1.0
208
    Properties:
209
      ServiceToken: !Sub ${OmicsVariantStoreLambda.Arn}
210
      VariantStoreName: !Sub ${OmicsVariantStoreName}
211
      ReferenceArn: !Sub ${OmicsImportReference.Arn}
212
213
  OmicsVariantStoreLambda:
214
    Type: AWS::Lambda::Function
215
    DependsOn:
216
      - OmicsVariantStoreLambdaRole
217
    Properties:
218
      Handler: create_variant_store_lambda.handler
219
      Runtime: python3.9
220
      FunctionName: !Sub ${OmicsResourcePrefix}-create-variant-store
221
      Code:
222
        S3Bucket: !Sub ${OmicsResourcesS3Bucket}
223
        S3Key: artifacts/create_variant_store_lambda.zip
224
      Role: !Sub ${OmicsVariantStoreLambdaRole.Arn}
225
      Timeout: 60
226
      
227
  OmicsVariantStoreLambdaRole:
228
    Type: AWS::IAM::Role
229
    Properties:
230
      AssumeRolePolicyDocument:
231
        Version: 2012-10-17
232
        Statement:
233
          - Action:
234
              - sts:AssumeRole
235
            Effect: Allow
236
            Principal:
237
              Service:
238
                - lambda.amazonaws.com
239
      Path: /
240
      Policies:
241
        - PolicyName: CreateVariantStorePolicy
242
          PolicyDocument:
243
            Statement:
244
              - Effect: Allow
245
                Action:
246
                  - logs:CreateLogGroup
247
                  - logs:CreateLogStream
248
                  - logs:PutLogEvents
249
                Resource:
250
                  - !Sub arn:aws:logs:${AWS::Region}:${AWS::AccountId}:log-group:/aws/lambda/*
251
              - Effect: Allow
252
                Action: 
253
                  - omics:*
254
                Resource: '*'
255
              - Effect: Allow
256
                Action:
257
                  - lambda:AddPermission
258
                  - lambda:RemovePermission
259
                  - events:PutRule
260
                  - events:DeleteRule
261
                  - events:PutTargets
262
                  - events:RemoveTargets
263
                Resource: '*'
264
              - Effect: Allow
265
                Action:
266
                  - ram:GetResourceShareInvitations
267
                  - ram:AcceptResourceShareInvitation
268
                Resource: '*'
269
  
270
  # OMICS IMPORT VARIANT (sample and 1kg) JOB
271
  OmicsImportVariantOneKg:
272
    Type: Custom::OmicsImportVariantOneKg
273
    DependsOn:
274
      - OmicsVariantStore
275
      - OmicsImportVariantLambda
276
    Version: 1.0
277
    Properties:
278
      ServiceToken: !Sub ${OmicsImportVariantLambda.Arn}
279
      VariantStoreName: !Sub ${OmicsVariantStoreName}
280
      OmicsImportVariantRoleArn: !Sub ${OmicsImportVariantJobRole.Arn}
281
      VcfS3Uri: !Sub s3://${OmicsDataS3Bucket}/${OneKgVcfS3Key}
282
283
  OmicsImportVariantSampleVcf:
284
    Type: Custom::OmicsImportVariantSampleVcf
285
    DependsOn:
286
      - OmicsVariantStore
287
      - OmicsImportVariantLambda
288
    Version: 1.0
289
    Properties:
290
      ServiceToken: !Sub ${OmicsImportVariantLambda.Arn}
291
      VariantStoreName: !Sub ${OmicsVariantStoreName}
292
      OmicsImportVariantRoleArn: !Sub ${OmicsImportVariantJobRole.Arn}
293
      VcfS3Uri: !Sub s3://${OmicsDataS3Bucket}/${SampleVcfS3Key}
294
295
  OmicsImportVariantLambda:
296
    Type: AWS::Lambda::Function
297
    DependsOn:
298
      - OmicsImportVariantLambdaRole
299
    Properties:
300
      Handler: import_variant_lambda.handler
301
      Runtime: python3.9
302
      FunctionName: !Sub ${OmicsResourcePrefix}-import-variant
303
      Code:
304
        S3Bucket: !Sub ${OmicsResourcesS3Bucket}
305
        S3Key: artifacts/import_variant_lambda.zip
306
      Role: !Sub ${OmicsImportVariantLambdaRole.Arn}
307
      Timeout: 60
308
  
309
  OmicsImportVariantLambdaRole:
310
    Type: AWS::IAM::Role
311
    DependsOn:
312
      - OmicsImportVariantJobRole
313
    Properties:
314
      AssumeRolePolicyDocument:
315
        Version: 2012-10-17
316
        Statement:
317
          - Action:
318
              - sts:AssumeRole
319
            Effect: Allow
320
            Principal:
321
              Service:
322
                - lambda.amazonaws.com
323
      Path: /
324
      Policies:
325
        - PolicyName: ImportVariantPolicy
326
          PolicyDocument:
327
            Statement:
328
              - Effect: Allow
329
                Action:
330
                  - logs:CreateLogGroup
331
                  - logs:CreateLogStream
332
                  - logs:PutLogEvents
333
                Resource:
334
                  - !Sub arn:aws:logs:${AWS::Region}:${AWS::AccountId}:log-group:/aws/lambda/*
335
              - Effect: Allow
336
                Action: 
337
                  - omics:*
338
                Resource: '*'
339
              - Effect: Allow
340
                Action:
341
                  - lambda:AddPermission
342
                  - lambda:RemovePermission
343
                  - events:PutRule
344
                  - events:DeleteRule
345
                  - events:PutTargets
346
                  - events:RemoveTargets
347
                Resource: '*'
348
              - Effect: Allow
349
                Action:
350
                  - iam:GetRole
351
                  - iam:PassRole
352
                Resource: !Sub ${OmicsImportVariantJobRole.Arn}
353
354
  OmicsImportVariantJobRole:
355
    Type: AWS::IAM::Role
356
    Properties:
357
      AssumeRolePolicyDocument:
358
        Version: 2012-10-17
359
        Statement:
360
          - Action:
361
              - sts:AssumeRole
362
            Effect: Allow
363
            Principal:
364
              Service:
365
                - omics.amazonaws.com
366
      Path: /
367
      Policies:
368
        - PolicyName: OmicsImportVariantJobRolePolicy
369
          PolicyDocument:
370
            Statement:
371
              - Effect: Allow
372
                Action:
373
                  - s3:GetObject
374
                  - s3:GetBucketLocation
375
                  - s3:ListBucket
376
                Resource:
377
                  - !Sub arn:aws:s3:::${OmicsDataS3Bucket}
378
                  - !Sub arn:aws:s3:::${OmicsDataS3Bucket}/${SampleVcfS3Key}
379
                  - !Sub arn:aws:s3:::${OmicsDataS3Bucket}/${OneKgVcfS3Key}
380
              - Effect: Allow
381
                Action:
382
                  - omics:ListReferences
383
                  - omics:GetReference
384
                  - omics:GetReferenceMetadata
385
                Resource: '*'
386
387
  # OMICS CREATE ANNOTATION STORE
388
  OmicsAnnotationStore:
389
    Type: Custom::OmicsAnnotationStore
390
    DependsOn:
391
      - OmicsAnnotationStoreLambda
392
      - OmicsImportReference
393
    Version: 1.0
394
    Properties:
395
      ServiceToken: !Sub ${OmicsAnnotationStoreLambda.Arn}
396
      AnnotationStoreName: !Sub ${OmicsAnnotationStoreName}
397
      ReferenceArn: !Sub ${OmicsImportReference.Arn}
398
      AnnotationStoreFormat: !Sub ${AnnotationStoreFormat}
399
  
400
  OmicsAnnotationStoreLambda:
401
    Type: AWS::Lambda::Function
402
    DependsOn:
403
      - OmicsAnnotationStoreLambdaRole
404
    Properties:
405
      Handler: create_annotation_store_lambda.handler
406
      Runtime: python3.9
407
      FunctionName: !Sub ${OmicsResourcePrefix}-create-annotation-store-v2
408
      Code:
409
        S3Bucket: !Sub ${OmicsResourcesS3Bucket}
410
        S3Key: artifacts/create_annotation_store_lambda.zip
411
      Role: !Sub ${OmicsAnnotationStoreLambdaRole.Arn}
412
      Timeout: 60
413
  
414
  OmicsAnnotationStoreLambdaRole:
415
    Type: AWS::IAM::Role
416
    Properties:
417
      AssumeRolePolicyDocument:
418
        Version: 2012-10-17
419
        Statement:
420
          - Action:
421
              - sts:AssumeRole
422
            Effect: Allow
423
            Principal:
424
              Service:
425
                - lambda.amazonaws.com
426
      Path: /
427
      Policies:
428
        - PolicyName: CreateAnnotationPolicy
429
          PolicyDocument:
430
            Statement:
431
              - Effect: Allow
432
                Action:
433
                  - logs:CreateLogGroup
434
                  - logs:CreateLogStream
435
                  - logs:PutLogEvents
436
                Resource:
437
                  - !Sub arn:aws:logs:${AWS::Region}:${AWS::AccountId}:log-group:/aws/lambda/*
438
              - Effect: Allow
439
                Action: 
440
                  - omics:*
441
                Resource: '*'
442
              - Effect: Allow
443
                Action:
444
                  - lambda:AddPermission
445
                  - lambda:RemovePermission
446
                  - events:PutRule
447
                  - events:DeleteRule
448
                  - events:PutTargets
449
                  - events:RemoveTargets
450
                Resource: '*'
451
              - Effect: Allow
452
                Action:
453
                  - ram:GetResourceShareInvitations
454
                  - ram:AcceptResourceShareInvitation
455
                Resource: '*'
456
  
457
  # OMICS CREATE IMPORT ANNOTATION JOB
458
  OmicsImportAnnotation:
459
    Type: Custom::OmicsImportAnnotation
460
    DependsOn:
461
      - OmicsAnnotationStore
462
      - OmicsImportAnnotationLambda
463
    Version: 1.0
464
    Properties:
465
      ServiceToken: !Sub ${OmicsImportAnnotationLambda.Arn}
466
      AnnotationStoreName: !Sub ${OmicsAnnotationStoreName}
467
      OmicsImportAnnotationRoleArn: !Sub ${OmicsImportAnnotationJobRole.Arn}
468
      AnnotationSourceS3Uri: !Sub s3://${OmicsDataS3Bucket}/${ClinvarS3Key}
469
    
470
  OmicsImportAnnotationLambda:
471
    Type: AWS::Lambda::Function
472
    DependsOn:
473
      - OmicsImportAnnotationLambdaRole
474
    Properties:
475
      Handler: import_annotation_lambda.handler
476
      Runtime: python3.9
477
      FunctionName: !Sub ${OmicsResourcePrefix}-import-annotation
478
      Code:
479
        S3Bucket: !Sub ${OmicsResourcesS3Bucket}
480
        S3Key: artifacts/import_annotation_lambda.zip
481
      Role: !Sub ${OmicsImportAnnotationLambdaRole.Arn}
482
      Timeout: 60
483
  
484
  OmicsImportAnnotationLambdaRole:
485
    Type: AWS::IAM::Role
486
    DependsOn:
487
      - OmicsImportAnnotationJobRole
488
    Properties:
489
      AssumeRolePolicyDocument:
490
        Version: 2012-10-17
491
        Statement:
492
          - Action:
493
              - sts:AssumeRole
494
            Effect: Allow
495
            Principal:
496
              Service:
497
                - lambda.amazonaws.com
498
      Path: /
499
      Policies:
500
        - PolicyName: ImportAnnotationPolicy
501
          PolicyDocument:
502
            Statement:
503
              - Effect: Allow
504
                Action:
505
                  - logs:CreateLogGroup
506
                  - logs:CreateLogStream
507
                  - logs:PutLogEvents
508
                Resource:
509
                  - !Sub arn:aws:logs:${AWS::Region}:${AWS::AccountId}:log-group:/aws/lambda/*
510
              - Effect: Allow
511
                Action: 
512
                  - omics:*
513
                Resource: '*'
514
              - Effect: Allow
515
                Action:
516
                  - lambda:AddPermission
517
                  - lambda:RemovePermission
518
                  - events:PutRule
519
                  - events:DeleteRule
520
                  - events:PutTargets
521
                  - events:RemoveTargets
522
                Resource: '*'
523
              - Effect: Allow
524
                Action:
525
                  - iam:GetRole
526
                  - iam:PassRole
527
                Resource: !Sub ${OmicsImportAnnotationJobRole.Arn}
528
  
529
  OmicsImportAnnotationJobRole:
530
    Type: AWS::IAM::Role
531
    Properties:
532
      AssumeRolePolicyDocument:
533
        Version: 2012-10-17
534
        Statement:
535
          - Action:
536
              - sts:AssumeRole
537
            Effect: Allow
538
            Principal:
539
              Service:
540
                - omics.amazonaws.com
541
      Path: /
542
      Policies:
543
        - PolicyName: ImportAnnotationJobRolePolicy
544
          PolicyDocument:
545
            Statement:
546
              - Effect: Allow
547
                Action:
548
                  - s3:GetObject
549
                  - s3:GetBucketLocation
550
                  - s3:ListBucket
551
                Resource:
552
                  - !Sub arn:aws:s3:::${OmicsDataS3Bucket}
553
                  - !Sub arn:aws:s3:::${OmicsDataS3Bucket}/${ClinvarS3Key}
554
              - Effect: Allow
555
                Action:
556
                  - omics:ListReferences
557
                  - omics:GetReference
558
                  - omics:GetReferenceMetadata
559
                Resource: '*'