@@ -11,179 +11,10 @@ Parameters:
11
11
12
12
Resources :
13
13
14
- VPC01 :
15
- Type : AWS::EC2::VPC
16
- Properties :
17
- CidrBlock : 10.0.0.0/16
18
- DependsOn : KinesisDataStream01
19
-
20
- PublicSubnet01 :
21
- Type : AWS::EC2::Subnet
22
- Properties :
23
- AvailabilityZone : !Select
24
- - 0
25
- - Fn::GetAZs : !Ref 'AWS::Region'
26
- CidrBlock : 10.0.0.0/24
27
- MapPublicIpOnLaunch : true
28
- VpcId :
29
- Ref : VPC01
30
-
31
- PublicSubnet02 :
32
- Type : AWS::EC2::Subnet
33
- Properties :
34
- AvailabilityZone : !Select
35
- - 1
36
- - Fn::GetAZs : !Ref 'AWS::Region'
37
- CidrBlock : 10.0.1.0/24
38
- MapPublicIpOnLaunch : true
39
- VpcId :
40
- Ref : VPC01
41
-
42
- PrivateSubnet01 :
43
- Type : AWS::EC2::Subnet
44
- Properties :
45
- VpcId : !Ref VPC01
46
- AvailabilityZone : !Select
47
- - 0
48
- - Fn::GetAZs : !Ref 'AWS::Region'
49
- CidrBlock : 10.0.10.0/24
50
- MapPublicIpOnLaunch : false
51
-
52
- PrivateSubnet02 :
53
- Type : AWS::EC2::Subnet
54
- Properties :
55
- VpcId : !Ref VPC01
56
- AvailabilityZone : !Select
57
- - 1
58
- - Fn::GetAZs : !Ref 'AWS::Region'
59
- CidrBlock : 10.0.11.0/24
60
- MapPublicIpOnLaunch : false
61
-
62
- InternetGateway01 :
63
- Type : AWS::EC2::InternetGateway
64
14
65
- InternetGatewayAttachment01 :
66
- Type : AWS::EC2::VPCGatewayAttachment
67
- Properties :
68
- InternetGatewayId : !Ref InternetGateway01
69
- VpcId : !Ref VPC01
70
15
71
- NatGateway01EIP :
72
- Type : AWS::EC2::EIP
73
- DependsOn : InternetGatewayAttachment01
74
- Properties :
75
- Domain : vpc
76
16
77
- NatGateway02EIP :
78
- Type : AWS::EC2::EIP
79
- DependsOn : InternetGatewayAttachment01
80
- Properties :
81
- Domain : vpc
82
17
83
- NatGateway01 :
84
- Type : AWS::EC2::NatGateway
85
- Properties :
86
- AllocationId : !GetAtt NatGateway01EIP.AllocationId
87
- SubnetId : !Ref PublicSubnet01
88
-
89
- NatGateway02 :
90
- Type : AWS::EC2::NatGateway
91
- Properties :
92
- AllocationId : !GetAtt NatGateway02EIP.AllocationId
93
- SubnetId : !Ref PublicSubnet02
94
-
95
- PublicRouteTable01 :
96
- Type : AWS::EC2::RouteTable
97
- Properties :
98
- VpcId : !Ref VPC01
99
-
100
- DefaultPublicRoute01 :
101
- Type : AWS::EC2::Route
102
- DependsOn : InternetGatewayAttachment01
103
- Properties :
104
- RouteTableId : !Ref PublicRouteTable01
105
- DestinationCidrBlock : 0.0.0.0/0
106
- GatewayId : !Ref InternetGateway01
107
-
108
- PublicSubnet01RouteTableAssociation :
109
- Type : AWS::EC2::SubnetRouteTableAssociation
110
- Properties :
111
- RouteTableId : !Ref PublicRouteTable01
112
- SubnetId : !Ref PublicSubnet01
113
-
114
- PublicSubnet02RouteTableAssociation :
115
- Type : AWS::EC2::SubnetRouteTableAssociation
116
- Properties :
117
- RouteTableId : !Ref PublicRouteTable01
118
- SubnetId : !Ref PublicSubnet02
119
-
120
- PrivateRouteTable01 :
121
- Type : AWS::EC2::RouteTable
122
- Properties :
123
- VpcId : !Ref VPC01
124
-
125
- DefaultPrivateRoute01 :
126
- Type : AWS::EC2::Route
127
- Properties :
128
- RouteTableId : !Ref PrivateRouteTable01
129
- DestinationCidrBlock : 0.0.0.0/0
130
- NatGatewayId : !Ref NatGateway01
131
-
132
- PrivateSubnet01RouteTableAssociation :
133
- Type : AWS::EC2::SubnetRouteTableAssociation
134
- Properties :
135
- RouteTableId : !Ref PrivateRouteTable01
136
- SubnetId : !Ref PrivateSubnet01
137
-
138
- PrivateRouteTable02 :
139
- Type : AWS::EC2::RouteTable
140
- Properties :
141
- VpcId : !Ref VPC01
142
-
143
- DefaultPrivateRoute02 :
144
- Type : AWS::EC2::Route
145
- Properties :
146
- RouteTableId : !Ref PrivateRouteTable02
147
- DestinationCidrBlock : 0.0.0.0/0
148
- NatGatewayId : !Ref NatGateway02
149
-
150
- PrivateSubnet02RouteTableAssociation :
151
- Type : AWS::EC2::SubnetRouteTableAssociation
152
- Properties :
153
- RouteTableId : !Ref PrivateRouteTable02
154
- SubnetId : !Ref PrivateSubnet02
155
-
156
- KinesisDataStream01 :
157
- Type : AWS::Kinesis::Stream
158
- Properties :
159
- Name : data-processing-stream
160
- ShardCount : 1
161
- DependsOn : CodeBuildTriggerRule01
162
-
163
- ECSCluster01 :
164
- Type : AWS::ECS::Cluster
165
- Properties :
166
- ClusterName : dataprocessor-cluster
167
-
168
- ProducerRepository01 :
169
- Type : AWS::ECR::Repository
170
- Properties :
171
- RepositoryName : kinesis-data-processor/producer
172
-
173
- ConsumerRepository01 :
174
- Type : AWS::ECR::Repository
175
- Properties :
176
- RepositoryName : kinesis-data-processor/producer
177
-
178
- ConsumerRepository01 :
179
- Type : AWS::ECR::Repository
180
- Properties :
181
- RepositoryName : kinesis-data-processor/consumer
182
-
183
- KinesisAutoscalerRepository01 :
184
- Type : AWS::ECR::Repository
185
- Properties :
186
- RepositoryName : kinesis-data-processor/kinesisautoscaler
187
18
188
19
189
20
ECSTaskExecutionRole01 :
@@ -215,134 +46,12 @@ Resources:
215
46
SourceSecurityGroupId : !Ref ALBSecurityGroup01
216
47
DependsOn : ALBSecurityGroup01
217
48
218
- ECSTaskProducerDefinition01 :
219
- Type : AWS::ECS::TaskDefinition
220
- Properties :
221
- Family : Producer
222
- NetworkMode : awsvpc
223
- Cpu : 2048
224
- Memory : 4096
225
- ContainerDefinitions :
226
- - Cpu : 2048
227
- Image : !Sub '${AWS::AccountId}.dkr.ecr.${AWS::Region}.amazonaws.com/kinesis-data-processor/producer'
228
- Memory : 4096
229
- Name : Producer
230
- PortMappings :
231
- - ContainerPort : 8080
232
- LogConfiguration :
233
- LogDriver : awslogs
234
- Options :
235
- awslogs-group : ecs/kinesis-data-processor-producer
236
- awslogs-region : !Ref 'AWS::Region'
237
- awslogs-stream-prefix : producer
238
- Environment :
239
- - Name : REGION
240
- Value : !Ref 'AWS::Region'
241
- - Name : STREAM_NAME
242
- Value : data-processing-stream
243
- ExecutionRoleArn : !Ref ECSTaskExecutionRole01
244
- TaskRoleArn : !Ref ECSTaskProducerRole01
245
- RequiresCompatibilities :
246
- - FARGATE
247
- DependsOn : ECSTaskLogGroup01
248
-
249
- ECSTaskProducerRole01 :
250
- Type : AWS::IAM::Role
251
- Properties :
252
- AssumeRolePolicyDocument :
253
- Statement :
254
- - Effect : Allow
255
- Principal :
256
- Service : ecs-tasks.amazonaws.com
257
- Action : ' sts:AssumeRole'
258
-
259
- ECSServiceProducer01 :
260
- Type : AWS::ECS::Service
261
- Properties :
262
- Cluster : !GetAtt ECSCluster01.Arn
263
- DesiredCount : 1
264
- LaunchType : FARGATE
265
- LoadBalancers :
266
- - ContainerName : Producer
267
- ContainerPort : 8080
268
- TargetGroupArn : !Ref ALBTargetGroup01
269
- ServiceName : dataProcessor-producerservice
270
- NetworkConfiguration :
271
- AwsvpcConfiguration :
272
- AssignPublicIp : DISABLED
273
- SecurityGroups :
274
- - !Ref ECSProducerServiceSecurityGroup01
275
- Subnets :
276
- - !Ref PrivateSubnet01
277
- - !Ref PrivateSubnet02
278
- SchedulingStrategy : REPLICA
279
- TaskDefinition : !Ref ECSTaskProducerDefinition01
280
- DependsOn : ALBListener01
281
-
282
- ECSServiceRoleProducer01 :
283
- Type : AWS::IAM::Role
284
- Properties :
285
- AssumeRolePolicyDocument :
286
- Version : 2008-10-17
287
- Statement :
288
- - Sid : ' '
289
- Effect : Allow
290
- Principal :
291
- Service : ecs.amazonaws.com
292
- Action : ' sts:AssumeRole'
293
- ManagedPolicyArns :
294
- - ' arn:aws:iam::aws:policy/service-role/AmazonEC2ContainerServiceRole'
295
49
296
- KPLPolicy01 :
297
- Type : AWS::IAM::ManagedPolicy
298
- Properties :
299
- ManagedPolicyName : KinesisProducerLibraryPolicy
300
- Roles :
301
- - !Ref ECSTaskProducerRole01
302
- PolicyDocument :
303
- Version : " 2012-10-17"
304
- Statement :
305
- -
306
- Effect : " Allow"
307
- Action :
308
- - kinesis:ListStreams
309
- - kinesis:ListShards
310
- - kinesis:PutRecords
311
- - kinesis:PutRecord
312
- Resource : !GetAtt KinesisDataStream01.Arn
313
- -
314
- Effect : " Allow"
315
- Action :
316
- - cloudwatch:PutMetricData
317
- Resource : " *"
318
- DependsOn : ECSTaskProducerRole01
319
50
320
- ECSAutoScalingTargetProducer01 :
321
- Type : AWS::ApplicationAutoScaling::ScalableTarget
322
- Properties :
323
- MinCapacity : 1
324
- MaxCapacity : 15
325
- ResourceId : !Join ['/', [service, !Ref ECSCluster01, !GetAtt ECSServiceProducer01.Name]]
326
- ScalableDimension : ecs:service:DesiredCount
327
- ServiceNamespace : ecs
328
- RoleARN : !Sub 'arn:aws:iam::${AWS::AccountId}:role/aws-service-role/ecs.application-autoscaling.amazonaws.com/AWSServiceRoleForApplicationAutoScaling_ECSService'
329
-
330
- ECSAutoScalingProducerPolicy :
331
- Type : AWS::ApplicationAutoScaling::ScalingPolicy
332
- Properties :
333
- PolicyType : TargetTrackingScaling
334
- PolicyName : KinesisProducerScalingPolicy
335
- ScalingTargetId : !Ref ECSAutoScalingTargetProducer01
336
- TargetTrackingScalingPolicyConfiguration :
337
- PredefinedMetricSpecification :
338
- PredefinedMetricType : ECSServiceAverageCPUUtilization
339
- ScaleInCooldown : 60
340
- ScaleOutCooldown : 60
341
- TargetValue : 65
342
51
343
52
ECSTaskLogGroup03 :
344
53
Type : AWS::Logs::LogGroup
345
- Properties :
54
+ Properties :
346
55
LogGroupName : ecs/kinesis-data-processor-kinesisAutoscaler
347
56
348
57
ECSAutoScalerServiceSecurityGroup01 :
0 commit comments