forked from cdk-patterns/serverless
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtemplate.yaml
1144 lines (1143 loc) · 40.4 KB
/
template.yaml
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
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
Resources:
TransformedDataB0572681:
Type: AWS::DynamoDB::Table
Properties:
KeySchema:
- AttributeName: id
KeyType: HASH
AttributeDefinitions:
- AttributeName: id
AttributeType: S
ProvisionedThroughput:
ReadCapacityUnits: 5
WriteCapacityUnits: 5
UpdateReplacePolicy: Retain
DeletionPolicy: Retain
Metadata:
aws:cdk:path: TheEventbridgeEtlStack/TransformedData/Resource
LandingBucket23FE90FB:
Type: AWS::S3::Bucket
UpdateReplacePolicy: Retain
DeletionPolicy: Retain
Metadata:
aws:cdk:path: TheEventbridgeEtlStack/LandingBucket/Resource
LandingBucketNotificationsEF1634C6:
Type: Custom::S3BucketNotifications
Properties:
ServiceToken:
Fn::GetAtt:
- BucketNotificationsHandler050a0587b7544547bf325f094a3db8347ECC3691
- Arn
BucketName:
Ref: LandingBucket23FE90FB
NotificationConfiguration:
QueueConfigurations:
- Events:
- s3:ObjectCreated:*
QueueArn:
Fn::GetAtt:
- newObjectInLandingBucketEventQueue67CBE2F2
- Arn
DependsOn:
- newObjectInLandingBucketEventQueuePolicy6B7CC541
- newObjectInLandingBucketEventQueue67CBE2F2
Metadata:
aws:cdk:path: TheEventbridgeEtlStack/LandingBucket/Notifications/Resource
newObjectInLandingBucketEventQueue67CBE2F2:
Type: AWS::SQS::Queue
Properties:
VisibilityTimeout: 300
Metadata:
aws:cdk:path: TheEventbridgeEtlStack/newObjectInLandingBucketEventQueue/Resource
newObjectInLandingBucketEventQueuePolicy6B7CC541:
Type: AWS::SQS::QueuePolicy
Properties:
PolicyDocument:
Statement:
- Action:
- sqs:SendMessage
- sqs:GetQueueAttributes
- sqs:GetQueueUrl
Condition:
ArnLike:
aws:SourceArn:
Fn::GetAtt:
- LandingBucket23FE90FB
- Arn
Effect: Allow
Principal:
Service: s3.amazonaws.com
Resource:
Fn::GetAtt:
- newObjectInLandingBucketEventQueue67CBE2F2
- Arn
Version: "2012-10-17"
Queues:
- Ref: newObjectInLandingBucketEventQueue67CBE2F2
Metadata:
aws:cdk:path: TheEventbridgeEtlStack/newObjectInLandingBucketEventQueue/Policy/Resource
BucketNotificationsHandler050a0587b7544547bf325f094a3db834RoleB6FB88EC:
Type: AWS::IAM::Role
Properties:
AssumeRolePolicyDocument:
Statement:
- Action: sts:AssumeRole
Effect: Allow
Principal:
Service: lambda.amazonaws.com
Version: "2012-10-17"
ManagedPolicyArns:
- Fn::Join:
- ""
- - "arn:"
- Ref: AWS::Partition
- :iam::aws:policy/service-role/AWSLambdaBasicExecutionRole
Metadata:
aws:cdk:path: TheEventbridgeEtlStack/BucketNotificationsHandler050a0587b7544547bf325f094a3db834/Role/Resource
BucketNotificationsHandler050a0587b7544547bf325f094a3db834RoleDefaultPolicy2CF63D36:
Type: AWS::IAM::Policy
Properties:
PolicyDocument:
Statement:
- Action: s3:PutBucketNotification
Effect: Allow
Resource: "*"
Version: "2012-10-17"
PolicyName: BucketNotificationsHandler050a0587b7544547bf325f094a3db834RoleDefaultPolicy2CF63D36
Roles:
- Ref: BucketNotificationsHandler050a0587b7544547bf325f094a3db834RoleB6FB88EC
Metadata:
aws:cdk:path: TheEventbridgeEtlStack/BucketNotificationsHandler050a0587b7544547bf325f094a3db834/Role/DefaultPolicy/Resource
BucketNotificationsHandler050a0587b7544547bf325f094a3db8347ECC3691:
Type: AWS::Lambda::Function
Properties:
Description: AWS CloudFormation handler for "Custom::S3BucketNotifications" resources (@aws-cdk/aws-s3)
Code:
ZipFile: >-
exports.handler = (event, context) => {
// eslint-disable-next-line @typescript-eslint/no-require-imports, import/no-extraneous-dependencies
const s3 = new (require('aws-sdk').S3)();
// eslint-disable-next-line @typescript-eslint/no-require-imports
const https = require("https");
// eslint-disable-next-line @typescript-eslint/no-require-imports
const url = require("url");
log(JSON.stringify(event, undefined, 2));
const props = event.ResourceProperties;
if (event.RequestType === 'Delete') {
props.NotificationConfiguration = {}; // this is how you clean out notifications
}
const req = {
Bucket: props.BucketName,
NotificationConfiguration: props.NotificationConfiguration
};
return s3.putBucketNotificationConfiguration(req, (err, data) => {
log({ err, data });
if (err) {
return submitResponse("FAILED", err.message + `\nMore information in CloudWatch Log Stream: ${context.logStreamName}`);
}
else {
return submitResponse("SUCCESS");
}
});
function log(obj) {
console.error(event.RequestId, event.StackId, event.LogicalResourceId, obj);
}
// tslint:disable-next-line:max-line-length
// adapted from https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-lambda-function-code.html#cfn-lambda-function-code-cfnresponsemodule
// to allow sending an error messge as a reason.
function submitResponse(responseStatus, reason) {
const responseBody = JSON.stringify({
Status: responseStatus,
Reason: reason || "See the details in CloudWatch Log Stream: " + context.logStreamName,
PhysicalResourceId: event.PhysicalResourceId || event.LogicalResourceId,
StackId: event.StackId,
RequestId: event.RequestId,
LogicalResourceId: event.LogicalResourceId,
NoEcho: false,
});
log({ responseBody });
const parsedUrl = url.parse(event.ResponseURL);
const options = {
hostname: parsedUrl.hostname,
port: 443,
path: parsedUrl.path,
method: "PUT",
headers: {
"content-type": "",
"content-length": responseBody.length
}
};
const request = https.request(options, (r) => {
log({ statusCode: r.statusCode, statusMessage: r.statusMessage });
context.done();
});
request.on("error", (error) => {
log({ sendError: error });
context.done();
});
request.write(responseBody);
request.end();
}
};
Handler: index.handler
Role:
Fn::GetAtt:
- BucketNotificationsHandler050a0587b7544547bf325f094a3db834RoleB6FB88EC
- Arn
Runtime: nodejs10.x
Timeout: 300
DependsOn:
- BucketNotificationsHandler050a0587b7544547bf325f094a3db834RoleDefaultPolicy2CF63D36
- BucketNotificationsHandler050a0587b7544547bf325f094a3db834RoleB6FB88EC
Metadata:
aws:cdk:path: TheEventbridgeEtlStack/BucketNotificationsHandler050a0587b7544547bf325f094a3db834/Resource
Vpc8378EB38:
Type: AWS::EC2::VPC
Properties:
CidrBlock: 10.0.0.0/16
EnableDnsHostnames: true
EnableDnsSupport: true
InstanceTenancy: default
Tags:
- Key: Name
Value: TheEventbridgeEtlStack/Vpc
Metadata:
aws:cdk:path: TheEventbridgeEtlStack/Vpc/Resource
VpcPublicSubnet1Subnet5C2D37C4:
Type: AWS::EC2::Subnet
Properties:
CidrBlock: 10.0.0.0/18
VpcId:
Ref: Vpc8378EB38
AvailabilityZone:
Fn::Select:
- 0
- Fn::GetAZs: ""
MapPublicIpOnLaunch: true
Tags:
- Key: Name
Value: TheEventbridgeEtlStack/Vpc/PublicSubnet1
- Key: aws-cdk:subnet-name
Value: Public
- Key: aws-cdk:subnet-type
Value: Public
Metadata:
aws:cdk:path: TheEventbridgeEtlStack/Vpc/PublicSubnet1/Subnet
VpcPublicSubnet1RouteTable6C95E38E:
Type: AWS::EC2::RouteTable
Properties:
VpcId:
Ref: Vpc8378EB38
Tags:
- Key: Name
Value: TheEventbridgeEtlStack/Vpc/PublicSubnet1
Metadata:
aws:cdk:path: TheEventbridgeEtlStack/Vpc/PublicSubnet1/RouteTable
VpcPublicSubnet1RouteTableAssociation97140677:
Type: AWS::EC2::SubnetRouteTableAssociation
Properties:
RouteTableId:
Ref: VpcPublicSubnet1RouteTable6C95E38E
SubnetId:
Ref: VpcPublicSubnet1Subnet5C2D37C4
Metadata:
aws:cdk:path: TheEventbridgeEtlStack/Vpc/PublicSubnet1/RouteTableAssociation
VpcPublicSubnet1DefaultRoute3DA9E72A:
Type: AWS::EC2::Route
Properties:
RouteTableId:
Ref: VpcPublicSubnet1RouteTable6C95E38E
DestinationCidrBlock: 0.0.0.0/0
GatewayId:
Ref: VpcIGWD7BA715C
DependsOn:
- VpcVPCGWBF912B6E
Metadata:
aws:cdk:path: TheEventbridgeEtlStack/Vpc/PublicSubnet1/DefaultRoute
VpcPublicSubnet1EIPD7E02669:
Type: AWS::EC2::EIP
Properties:
Domain: vpc
Tags:
- Key: Name
Value: TheEventbridgeEtlStack/Vpc/PublicSubnet1
Metadata:
aws:cdk:path: TheEventbridgeEtlStack/Vpc/PublicSubnet1/EIP
VpcPublicSubnet1NATGateway4D7517AA:
Type: AWS::EC2::NatGateway
Properties:
AllocationId:
Fn::GetAtt:
- VpcPublicSubnet1EIPD7E02669
- AllocationId
SubnetId:
Ref: VpcPublicSubnet1Subnet5C2D37C4
Tags:
- Key: Name
Value: TheEventbridgeEtlStack/Vpc/PublicSubnet1
Metadata:
aws:cdk:path: TheEventbridgeEtlStack/Vpc/PublicSubnet1/NATGateway
VpcPublicSubnet2Subnet691E08A3:
Type: AWS::EC2::Subnet
Properties:
CidrBlock: 10.0.64.0/18
VpcId:
Ref: Vpc8378EB38
AvailabilityZone:
Fn::Select:
- 1
- Fn::GetAZs: ""
MapPublicIpOnLaunch: true
Tags:
- Key: Name
Value: TheEventbridgeEtlStack/Vpc/PublicSubnet2
- Key: aws-cdk:subnet-name
Value: Public
- Key: aws-cdk:subnet-type
Value: Public
Metadata:
aws:cdk:path: TheEventbridgeEtlStack/Vpc/PublicSubnet2/Subnet
VpcPublicSubnet2RouteTable94F7E489:
Type: AWS::EC2::RouteTable
Properties:
VpcId:
Ref: Vpc8378EB38
Tags:
- Key: Name
Value: TheEventbridgeEtlStack/Vpc/PublicSubnet2
Metadata:
aws:cdk:path: TheEventbridgeEtlStack/Vpc/PublicSubnet2/RouteTable
VpcPublicSubnet2RouteTableAssociationDD5762D8:
Type: AWS::EC2::SubnetRouteTableAssociation
Properties:
RouteTableId:
Ref: VpcPublicSubnet2RouteTable94F7E489
SubnetId:
Ref: VpcPublicSubnet2Subnet691E08A3
Metadata:
aws:cdk:path: TheEventbridgeEtlStack/Vpc/PublicSubnet2/RouteTableAssociation
VpcPublicSubnet2DefaultRoute97F91067:
Type: AWS::EC2::Route
Properties:
RouteTableId:
Ref: VpcPublicSubnet2RouteTable94F7E489
DestinationCidrBlock: 0.0.0.0/0
GatewayId:
Ref: VpcIGWD7BA715C
DependsOn:
- VpcVPCGWBF912B6E
Metadata:
aws:cdk:path: TheEventbridgeEtlStack/Vpc/PublicSubnet2/DefaultRoute
VpcPublicSubnet2EIP3C605A87:
Type: AWS::EC2::EIP
Properties:
Domain: vpc
Tags:
- Key: Name
Value: TheEventbridgeEtlStack/Vpc/PublicSubnet2
Metadata:
aws:cdk:path: TheEventbridgeEtlStack/Vpc/PublicSubnet2/EIP
VpcPublicSubnet2NATGateway9182C01D:
Type: AWS::EC2::NatGateway
Properties:
AllocationId:
Fn::GetAtt:
- VpcPublicSubnet2EIP3C605A87
- AllocationId
SubnetId:
Ref: VpcPublicSubnet2Subnet691E08A3
Tags:
- Key: Name
Value: TheEventbridgeEtlStack/Vpc/PublicSubnet2
Metadata:
aws:cdk:path: TheEventbridgeEtlStack/Vpc/PublicSubnet2/NATGateway
VpcPrivateSubnet1Subnet536B997A:
Type: AWS::EC2::Subnet
Properties:
CidrBlock: 10.0.128.0/18
VpcId:
Ref: Vpc8378EB38
AvailabilityZone:
Fn::Select:
- 0
- Fn::GetAZs: ""
MapPublicIpOnLaunch: false
Tags:
- Key: Name
Value: TheEventbridgeEtlStack/Vpc/PrivateSubnet1
- Key: aws-cdk:subnet-name
Value: Private
- Key: aws-cdk:subnet-type
Value: Private
Metadata:
aws:cdk:path: TheEventbridgeEtlStack/Vpc/PrivateSubnet1/Subnet
VpcPrivateSubnet1RouteTableB2C5B500:
Type: AWS::EC2::RouteTable
Properties:
VpcId:
Ref: Vpc8378EB38
Tags:
- Key: Name
Value: TheEventbridgeEtlStack/Vpc/PrivateSubnet1
Metadata:
aws:cdk:path: TheEventbridgeEtlStack/Vpc/PrivateSubnet1/RouteTable
VpcPrivateSubnet1RouteTableAssociation70C59FA6:
Type: AWS::EC2::SubnetRouteTableAssociation
Properties:
RouteTableId:
Ref: VpcPrivateSubnet1RouteTableB2C5B500
SubnetId:
Ref: VpcPrivateSubnet1Subnet536B997A
Metadata:
aws:cdk:path: TheEventbridgeEtlStack/Vpc/PrivateSubnet1/RouteTableAssociation
VpcPrivateSubnet1DefaultRouteBE02A9ED:
Type: AWS::EC2::Route
Properties:
RouteTableId:
Ref: VpcPrivateSubnet1RouteTableB2C5B500
DestinationCidrBlock: 0.0.0.0/0
NatGatewayId:
Ref: VpcPublicSubnet1NATGateway4D7517AA
Metadata:
aws:cdk:path: TheEventbridgeEtlStack/Vpc/PrivateSubnet1/DefaultRoute
VpcPrivateSubnet2Subnet3788AAA1:
Type: AWS::EC2::Subnet
Properties:
CidrBlock: 10.0.192.0/18
VpcId:
Ref: Vpc8378EB38
AvailabilityZone:
Fn::Select:
- 1
- Fn::GetAZs: ""
MapPublicIpOnLaunch: false
Tags:
- Key: Name
Value: TheEventbridgeEtlStack/Vpc/PrivateSubnet2
- Key: aws-cdk:subnet-name
Value: Private
- Key: aws-cdk:subnet-type
Value: Private
Metadata:
aws:cdk:path: TheEventbridgeEtlStack/Vpc/PrivateSubnet2/Subnet
VpcPrivateSubnet2RouteTableA678073B:
Type: AWS::EC2::RouteTable
Properties:
VpcId:
Ref: Vpc8378EB38
Tags:
- Key: Name
Value: TheEventbridgeEtlStack/Vpc/PrivateSubnet2
Metadata:
aws:cdk:path: TheEventbridgeEtlStack/Vpc/PrivateSubnet2/RouteTable
VpcPrivateSubnet2RouteTableAssociationA89CAD56:
Type: AWS::EC2::SubnetRouteTableAssociation
Properties:
RouteTableId:
Ref: VpcPrivateSubnet2RouteTableA678073B
SubnetId:
Ref: VpcPrivateSubnet2Subnet3788AAA1
Metadata:
aws:cdk:path: TheEventbridgeEtlStack/Vpc/PrivateSubnet2/RouteTableAssociation
VpcPrivateSubnet2DefaultRoute060D2087:
Type: AWS::EC2::Route
Properties:
RouteTableId:
Ref: VpcPrivateSubnet2RouteTableA678073B
DestinationCidrBlock: 0.0.0.0/0
NatGatewayId:
Ref: VpcPublicSubnet2NATGateway9182C01D
Metadata:
aws:cdk:path: TheEventbridgeEtlStack/Vpc/PrivateSubnet2/DefaultRoute
VpcIGWD7BA715C:
Type: AWS::EC2::InternetGateway
Properties:
Tags:
- Key: Name
Value: TheEventbridgeEtlStack/Vpc
Metadata:
aws:cdk:path: TheEventbridgeEtlStack/Vpc/IGW
VpcVPCGWBF912B6E:
Type: AWS::EC2::VPCGatewayAttachment
Properties:
VpcId:
Ref: Vpc8378EB38
InternetGatewayId:
Ref: VpcIGWD7BA715C
Metadata:
aws:cdk:path: TheEventbridgeEtlStack/Vpc/VPCGW
Ec2ClusterEE43E89D:
Type: AWS::ECS::Cluster
Metadata:
aws:cdk:path: TheEventbridgeEtlStack/Ec2Cluster/Resource
FargateTaskDefinitionTaskRoleE3C2BCAA:
Type: AWS::IAM::Role
Properties:
AssumeRolePolicyDocument:
Statement:
- Action: sts:AssumeRole
Effect: Allow
Principal:
Service: ecs-tasks.amazonaws.com
Version: "2012-10-17"
Metadata:
aws:cdk:path: TheEventbridgeEtlStack/FargateTaskDefinition/TaskRole/Resource
FargateTaskDefinitionTaskRoleDefaultPolicy798E9D9D:
Type: AWS::IAM::Policy
Properties:
PolicyDocument:
Statement:
- Action: events:PutEvents
Effect: Allow
Resource: "*"
- Action:
- s3:GetObject*
- s3:GetBucket*
- s3:List*
Effect: Allow
Resource:
- Fn::GetAtt:
- LandingBucket23FE90FB
- Arn
- Fn::Join:
- ""
- - Fn::GetAtt:
- LandingBucket23FE90FB
- Arn
- /*
Version: "2012-10-17"
PolicyName: FargateTaskDefinitionTaskRoleDefaultPolicy798E9D9D
Roles:
- Ref: FargateTaskDefinitionTaskRoleE3C2BCAA
Metadata:
aws:cdk:path: TheEventbridgeEtlStack/FargateTaskDefinition/TaskRole/DefaultPolicy/Resource
FargateTaskDefinition8E3B365E:
Type: AWS::ECS::TaskDefinition
Properties:
ContainerDefinitions:
- Environment:
- Name: S3_BUCKET_NAME
Value:
Ref: LandingBucket23FE90FB
- Name: S3_OBJECT_KEY
Value: ""
Essential: true
Image:
Fn::Join:
- ""
- - Ref: AWS::AccountId
- .dkr.ecr.
- Ref: AWS::Region
- "."
- Ref: AWS::URLSuffix
- /aws-cdk/assets:c0b516e9cf4b40ccd301dfe80b21137805cbf3b84b1b0813797cfec33c439d2e
LogConfiguration:
LogDriver: awslogs
Options:
awslogs-group:
Ref: FargateTaskDefinitionAppContainerLogGroup20407D7C
awslogs-stream-prefix: TheEventBridgeETL
awslogs-region:
Ref: AWS::Region
Name: AppContainer
Cpu: "256"
ExecutionRoleArn:
Fn::GetAtt:
- FargateTaskDefinitionExecutionRoleE69A8E33
- Arn
Family: TheEventbridgeEtlStackFargateTaskDefinitionE442270B
Memory: "512"
NetworkMode: awsvpc
RequiresCompatibilities:
- FARGATE
TaskRoleArn:
Fn::GetAtt:
- FargateTaskDefinitionTaskRoleE3C2BCAA
- Arn
Metadata:
aws:cdk:path: TheEventbridgeEtlStack/FargateTaskDefinition/Resource
FargateTaskDefinitionAppContainerLogGroup20407D7C:
Type: AWS::Logs::LogGroup
Properties:
RetentionInDays: 7
UpdateReplacePolicy: Retain
DeletionPolicy: Retain
Metadata:
aws:cdk:path: TheEventbridgeEtlStack/FargateTaskDefinition/AppContainer/LogGroup/Resource
FargateTaskDefinitionExecutionRoleE69A8E33:
Type: AWS::IAM::Role
Properties:
AssumeRolePolicyDocument:
Statement:
- Action: sts:AssumeRole
Effect: Allow
Principal:
Service: ecs-tasks.amazonaws.com
Version: "2012-10-17"
Metadata:
aws:cdk:path: TheEventbridgeEtlStack/FargateTaskDefinition/ExecutionRole/Resource
FargateTaskDefinitionExecutionRoleDefaultPolicy1632DA52:
Type: AWS::IAM::Policy
Properties:
PolicyDocument:
Statement:
- Action:
- ecr:BatchCheckLayerAvailability
- ecr:GetDownloadUrlForLayer
- ecr:BatchGetImage
Effect: Allow
Resource:
Fn::Join:
- ""
- - "arn:"
- Ref: AWS::Partition
- ":ecr:"
- Ref: AWS::Region
- ":"
- Ref: AWS::AccountId
- :repository/aws-cdk/assets
- Action: ecr:GetAuthorizationToken
Effect: Allow
Resource: "*"
- Action:
- logs:CreateLogStream
- logs:PutLogEvents
Effect: Allow
Resource:
Fn::GetAtt:
- FargateTaskDefinitionAppContainerLogGroup20407D7C
- Arn
Version: "2012-10-17"
PolicyName: FargateTaskDefinitionExecutionRoleDefaultPolicy1632DA52
Roles:
- Ref: FargateTaskDefinitionExecutionRoleE69A8E33
Metadata:
aws:cdk:path: TheEventbridgeEtlStack/FargateTaskDefinition/ExecutionRole/DefaultPolicy/Resource
extractLambdaHandlerServiceRole8A50F829:
Type: AWS::IAM::Role
Properties:
AssumeRolePolicyDocument:
Statement:
- Action: sts:AssumeRole
Effect: Allow
Principal:
Service: lambda.amazonaws.com
Version: "2012-10-17"
ManagedPolicyArns:
- Fn::Join:
- ""
- - "arn:"
- Ref: AWS::Partition
- :iam::aws:policy/service-role/AWSLambdaBasicExecutionRole
Metadata:
aws:cdk:path: TheEventbridgeEtlStack/extractLambdaHandler/ServiceRole/Resource
extractLambdaHandlerServiceRoleDefaultPolicyB880CB8F:
Type: AWS::IAM::Policy
Properties:
PolicyDocument:
Statement:
- Action:
- sqs:ReceiveMessage
- sqs:ChangeMessageVisibility
- sqs:GetQueueUrl
- sqs:DeleteMessage
- sqs:GetQueueAttributes
Effect: Allow
Resource:
Fn::GetAtt:
- newObjectInLandingBucketEventQueue67CBE2F2
- Arn
- Action: events:PutEvents
Effect: Allow
Resource: "*"
- Action: ecs:RunTask
Effect: Allow
Resource:
Ref: FargateTaskDefinition8E3B365E
- Action: iam:PassRole
Effect: Allow
Resource:
- Fn::GetAtt:
- FargateTaskDefinitionExecutionRoleE69A8E33
- Arn
- Fn::GetAtt:
- FargateTaskDefinitionTaskRoleE3C2BCAA
- Arn
Version: "2012-10-17"
PolicyName: extractLambdaHandlerServiceRoleDefaultPolicyB880CB8F
Roles:
- Ref: extractLambdaHandlerServiceRole8A50F829
Metadata:
aws:cdk:path: TheEventbridgeEtlStack/extractLambdaHandler/ServiceRole/DefaultPolicy/Resource
extractLambdaHandlerD06B8F09:
Type: AWS::Lambda::Function
Properties:
Code:
S3Bucket:
Ref: AssetParameters3d4073f7e091374918e3a906e9ed910bfac6f3e80c9bbddc9001f6b44a1bc8efS3BucketB50581FD
S3Key:
Fn::Join:
- ""
- - Fn::Select:
- 0
- Fn::Split:
- "||"
- Ref: AssetParameters3d4073f7e091374918e3a906e9ed910bfac6f3e80c9bbddc9001f6b44a1bc8efS3VersionKey9353037D
- Fn::Select:
- 1
- Fn::Split:
- "||"
- Ref: AssetParameters3d4073f7e091374918e3a906e9ed910bfac6f3e80c9bbddc9001f6b44a1bc8efS3VersionKey9353037D
Handler: s3SqsEventConsumer.handler
Role:
Fn::GetAtt:
- extractLambdaHandlerServiceRole8A50F829
- Arn
Runtime: nodejs12.x
Environment:
Variables:
CLUSTER_NAME:
Ref: Ec2ClusterEE43E89D
TASK_DEFINITION:
Ref: FargateTaskDefinition8E3B365E
SUBNETS:
Fn::Join:
- ""
- - '["'
- Ref: VpcPrivateSubnet1Subnet536B997A
- '","'
- Ref: VpcPrivateSubnet2Subnet3788AAA1
- '"]'
CONTAINER_NAME: AppContainer
ReservedConcurrentExecutions: 2
DependsOn:
- extractLambdaHandlerServiceRoleDefaultPolicyB880CB8F
- extractLambdaHandlerServiceRole8A50F829
Metadata:
aws:cdk:path: TheEventbridgeEtlStack/extractLambdaHandler/Resource
aws:asset:path: asset.3d4073f7e091374918e3a906e9ed910bfac6f3e80c9bbddc9001f6b44a1bc8ef
aws:asset:property: Code
extractLambdaHandlerSqsEventSourceTheEventbridgeEtlStacknewObjectInLandingBucketEventQueueA6103BFC894EEFC5:
Type: AWS::Lambda::EventSourceMapping
Properties:
EventSourceArn:
Fn::GetAtt:
- newObjectInLandingBucketEventQueue67CBE2F2
- Arn
FunctionName:
Ref: extractLambdaHandlerD06B8F09
Metadata:
aws:cdk:path: TheEventbridgeEtlStack/extractLambdaHandler/SqsEventSource:TheEventbridgeEtlStacknewObjectInLandingBucketEventQueueA6103BFC/Resource
TransformLambdaHandlerServiceRole710C039E:
Type: AWS::IAM::Role
Properties:
AssumeRolePolicyDocument:
Statement:
- Action: sts:AssumeRole
Effect: Allow
Principal:
Service: lambda.amazonaws.com
Version: "2012-10-17"
ManagedPolicyArns:
- Fn::Join:
- ""
- - "arn:"
- Ref: AWS::Partition
- :iam::aws:policy/service-role/AWSLambdaBasicExecutionRole
Metadata:
aws:cdk:path: TheEventbridgeEtlStack/TransformLambdaHandler/ServiceRole/Resource
TransformLambdaHandlerServiceRoleDefaultPolicy94353D30:
Type: AWS::IAM::Policy
Properties:
PolicyDocument:
Statement:
- Action: events:PutEvents
Effect: Allow
Resource: "*"
Version: "2012-10-17"
PolicyName: TransformLambdaHandlerServiceRoleDefaultPolicy94353D30
Roles:
- Ref: TransformLambdaHandlerServiceRole710C039E
Metadata:
aws:cdk:path: TheEventbridgeEtlStack/TransformLambdaHandler/ServiceRole/DefaultPolicy/Resource
TransformLambdaHandler60ABE8EE:
Type: AWS::Lambda::Function
Properties:
Code:
S3Bucket:
Ref: AssetParameters3f21814646b7943d7f4523e57db6b5ae19f3f5910bbc04013fae00c7a0a4a23dS3Bucket52730867
S3Key:
Fn::Join:
- ""
- - Fn::Select:
- 0
- Fn::Split:
- "||"
- Ref: AssetParameters3f21814646b7943d7f4523e57db6b5ae19f3f5910bbc04013fae00c7a0a4a23dS3VersionKeyA72746F6
- Fn::Select:
- 1
- Fn::Split:
- "||"
- Ref: AssetParameters3f21814646b7943d7f4523e57db6b5ae19f3f5910bbc04013fae00c7a0a4a23dS3VersionKeyA72746F6
Handler: transform.handler
Role:
Fn::GetAtt:
- TransformLambdaHandlerServiceRole710C039E
- Arn
Runtime: nodejs12.x
ReservedConcurrentExecutions: 2
Timeout: 3
DependsOn:
- TransformLambdaHandlerServiceRoleDefaultPolicy94353D30
- TransformLambdaHandlerServiceRole710C039E
Metadata:
aws:cdk:path: TheEventbridgeEtlStack/TransformLambdaHandler/Resource
aws:asset:path: asset.3f21814646b7943d7f4523e57db6b5ae19f3f5910bbc04013fae00c7a0a4a23d
aws:asset:property: Code
TransformLambdaHandlerAllowEventRuleTheEventbridgeEtlStacktransformRuleF338DDCDB98C30A0:
Type: AWS::Lambda::Permission
Properties:
Action: lambda:InvokeFunction
FunctionName:
Fn::GetAtt:
- TransformLambdaHandler60ABE8EE
- Arn
Principal: events.amazonaws.com
SourceArn:
Fn::GetAtt:
- transformRuleFEA34632
- Arn
Metadata:
aws:cdk:path: TheEventbridgeEtlStack/TransformLambdaHandler/AllowEventRuleTheEventbridgeEtlStacktransformRuleF338DDCD
transformRuleFEA34632:
Type: AWS::Events::Rule
Properties:
Description: Data extracted from S3, Needs transformed
EventPattern:
source:
- cdkpatterns.the-eventbridge-etl
detail-type:
- s3RecordExtraction
detail:
status:
- extracted
State: ENABLED
Targets:
- Arn:
Fn::GetAtt:
- TransformLambdaHandler60ABE8EE
- Arn
Id: Target0
Metadata:
aws:cdk:path: TheEventbridgeEtlStack/transformRule/Resource
LoadLambdaHandlerServiceRole83E61748:
Type: AWS::IAM::Role
Properties:
AssumeRolePolicyDocument:
Statement:
- Action: sts:AssumeRole
Effect: Allow
Principal:
Service: lambda.amazonaws.com
Version: "2012-10-17"
ManagedPolicyArns:
- Fn::Join:
- ""
- - "arn:"
- Ref: AWS::Partition
- :iam::aws:policy/service-role/AWSLambdaBasicExecutionRole
Metadata:
aws:cdk:path: TheEventbridgeEtlStack/LoadLambdaHandler/ServiceRole/Resource
LoadLambdaHandlerServiceRoleDefaultPolicy63B03BA2:
Type: AWS::IAM::Policy
Properties:
PolicyDocument:
Statement:
- Action: events:PutEvents
Effect: Allow
Resource: "*"
- Action:
- dynamodb:BatchGetItem
- dynamodb:GetRecords
- dynamodb:GetShardIterator
- dynamodb:Query
- dynamodb:GetItem
- dynamodb:Scan
- dynamodb:BatchWriteItem
- dynamodb:PutItem
- dynamodb:UpdateItem
- dynamodb:DeleteItem
Effect: Allow
Resource:
- Fn::GetAtt:
- TransformedDataB0572681
- Arn
- Ref: AWS::NoValue
Version: "2012-10-17"
PolicyName: LoadLambdaHandlerServiceRoleDefaultPolicy63B03BA2
Roles:
- Ref: LoadLambdaHandlerServiceRole83E61748
Metadata:
aws:cdk:path: TheEventbridgeEtlStack/LoadLambdaHandler/ServiceRole/DefaultPolicy/Resource
LoadLambdaHandlerFDA03D53:
Type: AWS::Lambda::Function
Properties:
Code:
S3Bucket:
Ref: AssetParametersf60819695c7a11886d0ef1100dc0dcf6166c79bfe22a93e8b0e5e148e26cc798S3Bucket689341CE
S3Key:
Fn::Join:
- ""
- - Fn::Select:
- 0
- Fn::Split:
- "||"
- Ref: AssetParametersf60819695c7a11886d0ef1100dc0dcf6166c79bfe22a93e8b0e5e148e26cc798S3VersionKey4A45C95F
- Fn::Select:
- 1
- Fn::Split:
- "||"
- Ref: AssetParametersf60819695c7a11886d0ef1100dc0dcf6166c79bfe22a93e8b0e5e148e26cc798S3VersionKey4A45C95F
Handler: load.handler
Role:
Fn::GetAtt:
- LoadLambdaHandlerServiceRole83E61748
- Arn
Runtime: nodejs12.x
Environment:
Variables:
TABLE_NAME:
Ref: TransformedDataB0572681
ReservedConcurrentExecutions: 2
Timeout: 3
DependsOn:
- LoadLambdaHandlerServiceRoleDefaultPolicy63B03BA2
- LoadLambdaHandlerServiceRole83E61748
Metadata:
aws:cdk:path: TheEventbridgeEtlStack/LoadLambdaHandler/Resource
aws:asset:path: asset.f60819695c7a11886d0ef1100dc0dcf6166c79bfe22a93e8b0e5e148e26cc798
aws:asset:property: Code
LoadLambdaHandlerAllowEventRuleTheEventbridgeEtlStackloadRuleE4CE7871B2567CFC:
Type: AWS::Lambda::Permission
Properties:
Action: lambda:InvokeFunction
FunctionName:
Fn::GetAtt:
- LoadLambdaHandlerFDA03D53
- Arn
Principal: events.amazonaws.com
SourceArn:
Fn::GetAtt:
- loadRuleF0FAF418
- Arn
Metadata:
aws:cdk:path: TheEventbridgeEtlStack/LoadLambdaHandler/AllowEventRuleTheEventbridgeEtlStackloadRuleE4CE7871
loadRuleF0FAF418:
Type: AWS::Events::Rule
Properties:
Description: Data transformed, Needs loaded into dynamodb
EventPattern:
source:
- cdkpatterns.the-eventbridge-etl
detail-type:
- transform
detail:
status:
- transformed
State: ENABLED
Targets:
- Arn:
Fn::GetAtt:
- LoadLambdaHandlerFDA03D53
- Arn
Id: Target0
Metadata:
aws:cdk:path: TheEventbridgeEtlStack/loadRule/Resource
ObserveLambdaHandlerServiceRole040C69BA:
Type: AWS::IAM::Role
Properties:
AssumeRolePolicyDocument:
Statement:
- Action: sts:AssumeRole
Effect: Allow
Principal:
Service: lambda.amazonaws.com
Version: "2012-10-17"
ManagedPolicyArns:
- Fn::Join:
- ""
- - "arn:"
- Ref: AWS::Partition
- :iam::aws:policy/service-role/AWSLambdaBasicExecutionRole
Metadata:
aws:cdk:path: TheEventbridgeEtlStack/ObserveLambdaHandler/ServiceRole/Resource
ObserveLambdaHandler685FFDBB:
Type: AWS::Lambda::Function
Properties:
Code:
S3Bucket:
Ref: AssetParameters5c46dab3af6a6aa03e1f093055d6a09930619300ec83c4023322ab4412b858f1S3Bucket31B40717
S3Key:
Fn::Join:
- ""
- - Fn::Select:
- 0
- Fn::Split:
- "||"
- Ref: AssetParameters5c46dab3af6a6aa03e1f093055d6a09930619300ec83c4023322ab4412b858f1S3VersionKeyCD75E4AB
- Fn::Select:
- 1
- Fn::Split:
- "||"
- Ref: AssetParameters5c46dab3af6a6aa03e1f093055d6a09930619300ec83c4023322ab4412b858f1S3VersionKeyCD75E4AB
Handler: observe.handler
Role:
Fn::GetAtt:
- ObserveLambdaHandlerServiceRole040C69BA
- Arn
Runtime: nodejs12.x
Timeout: 3
DependsOn: