-
Notifications
You must be signed in to change notification settings - Fork 1
/
OMEROonFargate.yml
476 lines (474 loc) · 14.7 KB
/
OMEROonFargate.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
AWSTemplateFormatVersion: '2010-09-09'
Conditions:
CreateCluster: !Equals
- ''
- !Ref 'ParameterClusterName'
CreateLoadBalancer: !Equals
- ''
- !Ref 'ParameterLoadBalancerARN'
Description: CloudFormation template created by Docker for deploying applications
on Amazon ECS
Parameters:
ParameterClusterName:
Description: Name of the ECS cluster to deploy to (optional)
Type: String
ParameterLoadBalancerARN:
Description: Name of the LoadBalancer to connect to (optional)
Type: String
ParameterSubnet1Id:
Description: SubnetId, for Availability Zone 1 in the region in your VPC
Type: AWS::EC2::Subnet::Id
ParameterSubnet2Id:
Description: SubnetId, for Availability Zone 2 in the region in your VPC
Type: AWS::EC2::Subnet::Id
ParameterVPCId:
Description: ID of the VPC
Type: AWS::EC2::VPC::Id
Resources:
CloudMap:
Type: AWS::ServiceDiscovery::PrivateDnsNamespace
Properties:
Description: Service Map for Docker Compose project dockerexampleomero
Name: dockerexampleomero.local
Vpc: !Ref 'ParameterVPCId'
Cluster:
Type: AWS::ECS::Cluster
Condition: CreateCluster
Properties:
ClusterName: dockerexampleomero
Tags:
- Key: com.docker.compose.project
Value: dockerexampleomero
DatabaseService:
Type: AWS::ECS::Service
Properties:
Cluster: !If
- CreateCluster
- !Ref 'Cluster'
- !Ref 'ParameterClusterName'
DeploymentConfiguration:
MaximumPercent: 200
MinimumHealthyPercent: 100
DeploymentController:
Type: ECS
DesiredCount: 1
LaunchType: FARGATE
NetworkConfiguration:
AwsvpcConfiguration:
AssignPublicIp: ENABLED
SecurityGroups:
- !Ref 'DockerexampleomeroOmeroNetwork'
Subnets:
- !Ref 'ParameterSubnet1Id'
- !Ref 'ParameterSubnet2Id'
PropagateTags: SERVICE
SchedulingStrategy: REPLICA
ServiceRegistries:
- RegistryArn: !GetAtt 'DatabaseServiceDiscoveryEntry.Arn'
Tags:
- Key: com.docker.compose.project
Value: dockerexampleomero
- Key: com.docker.compose.service
Value: database
TaskDefinition: !Ref 'DatabaseTaskDefinition'
DatabaseServiceDiscoveryEntry:
Type: AWS::ServiceDiscovery::Service
Properties:
Description: '"database" service discovery entry in Cloud Map'
DnsConfig:
DnsRecords:
- TTL: 60
Type: A
RoutingPolicy: MULTIVALUE
HealthCheckCustomConfig:
FailureThreshold: 1
Name: database
NamespaceId: !Ref 'CloudMap'
DatabaseTaskDefinition:
Type: AWS::ECS::TaskDefinition
Properties:
ContainerDefinitions:
- Environment:
- Name: POSTGRES_DB
Value: omero
- Name: POSTGRES_PASSWORD
Value: omero
- Name: LOCALDOMAIN
Value: !Join
- ''
- - !Ref 'AWS::Region'
- .compute.internal
- ' dockerexampleomero.local'
- Name: POSTGRES_USER
Value: omero
Essential: true
Image: postgres:11
LinuxParameters: {}
LogConfiguration:
LogDriver: awslogs
Options:
awslogs-group: !Ref 'LogGroup'
awslogs-region: !Ref 'AWS::Region'
awslogs-stream-prefix: dockerexampleomero
Name: database
Cpu: '2048'
Memory: '4096'
ExecutionRoleArn: !Ref 'DatabaseTaskExecutionRole'
Family: dockerexampleomero-database
NetworkMode: awsvpc
RequiresCompatibilities:
- FARGATE
DatabaseTaskExecutionRole:
Type: AWS::IAM::Role
Properties:
AssumeRolePolicyDocument:
Statement:
- Action:
- sts:AssumeRole
Effect: Allow
Principal:
Service: ecs-tasks.amazonaws.com
Version: '2012-10-17'
ManagedPolicyArns:
- arn:aws:iam::aws:policy/service-role/AmazonECSTaskExecutionRolePolicy
- arn:aws:iam::aws:policy/AmazonEC2ContainerRegistryReadOnly
DockerexampleomeroLoadBalancer:
Condition: CreateLoadBalancer
Type: AWS::ElasticLoadBalancingV2::LoadBalancer
Properties:
Name: DockerexampleomeroLoadBalancer
Scheme: internet-facing
Subnets:
- !Ref 'ParameterSubnet1Id'
- !Ref 'ParameterSubnet2Id'
Tags:
- Key: com.docker.compose.project
Value: dockerexampleomero
Type: network
DockerexampleomeroOmeroNetwork:
Type: AWS::EC2::SecurityGroup
Properties:
GroupDescription: dockerexampleomero omero Security Group
GroupName: DockerexampleomeroOmeroNetwork
SecurityGroupIngress:
- CidrIp: '0.0.0.0/0'
Description: omeroserver:4063/tcp
FromPort: 4063
IpProtocol: TCP
ToPort: 4063
- CidrIp: '0.0.0.0/0'
Description: omeroserver:4064/tcp
FromPort: 4064
IpProtocol: TCP
ToPort: 4064
- CidrIp: '0.0.0.0/0'
Description: omeroweb:4080/tcp
FromPort: 4080
IpProtocol: TCP
ToPort: 4080
Tags:
- Key: com.docker.compose.project
Value: dockerexampleomero
- Key: com.docker.compose.network
Value: omero
VpcId: !Ref 'ParameterVPCId'
DockerexampleomeroOmeroNetworkIngress:
Type: AWS::EC2::SecurityGroupIngress
Properties:
Description: Allow communication within network omero
GroupId: !Ref 'DockerexampleomeroOmeroNetwork'
IpProtocol: '-1'
SourceSecurityGroupId: !Ref 'DockerexampleomeroOmeroNetwork'
LogGroup:
Type: AWS::Logs::LogGroup
Properties:
LogGroupName: /docker-compose/dockerexampleomero
OmeroserverService:
Type: AWS::ECS::Service
DependsOn:
- OmeroserverTCP4063Listener
- OmeroserverTCP4064Listener
Properties:
Cluster: !If
- CreateCluster
- !Ref 'Cluster'
- !Ref 'ParameterClusterName'
DeploymentConfiguration:
MaximumPercent: 200
MinimumHealthyPercent: 100
DeploymentController:
Type: ECS
DesiredCount: 1
LaunchType: FARGATE
LoadBalancers:
- ContainerName: omeroserver
ContainerPort: 4063
TargetGroupArn: !Ref 'OmeroserverTCP4063TargetGroup'
- ContainerName: omeroserver
ContainerPort: 4064
TargetGroupArn: !Ref 'OmeroserverTCP4064TargetGroup'
NetworkConfiguration:
AwsvpcConfiguration:
AssignPublicIp: ENABLED
SecurityGroups:
- !Ref 'DockerexampleomeroOmeroNetwork'
Subnets:
- !Ref 'ParameterSubnet1Id'
- !Ref 'ParameterSubnet2Id'
PropagateTags: SERVICE
SchedulingStrategy: REPLICA
ServiceRegistries:
- RegistryArn: !GetAtt 'OmeroserverServiceDiscoveryEntry.Arn'
Tags:
- Key: com.docker.compose.project
Value: dockerexampleomero
- Key: com.docker.compose.service
Value: omeroserver
TaskDefinition: !Ref 'OmeroserverTaskDefinition'
OmeroserverServiceDiscoveryEntry:
Type: AWS::ServiceDiscovery::Service
Properties:
Description: '"omeroserver" service discovery entry in Cloud Map'
DnsConfig:
DnsRecords:
- TTL: 60
Type: A
RoutingPolicy: MULTIVALUE
HealthCheckCustomConfig:
FailureThreshold: 1
Name: omeroserver
NamespaceId: !Ref 'CloudMap'
OmeroserverTCP4063Listener:
Type: AWS::ElasticLoadBalancingV2::Listener
Properties:
DefaultActions:
- ForwardConfig:
TargetGroups:
- TargetGroupArn: !Ref 'OmeroserverTCP4063TargetGroup'
Type: forward
LoadBalancerArn: !If
- CreateLoadBalancer
- !Ref 'DockerexampleomeroLoadBalancer'
- !Ref 'ParameterLoadBalancerARN'
Port: 4063
Protocol: TCP
OmeroserverTCP4063TargetGroup:
Type: AWS::ElasticLoadBalancingV2::TargetGroup
Properties:
Port: 4063
Protocol: TCP
Tags:
- Key: com.docker.compose.project
Value: dockerexampleomero
TargetType: ip
VpcId: !Ref 'ParameterVPCId'
OmeroserverTCP4064Listener:
Type: AWS::ElasticLoadBalancingV2::Listener
Properties:
DefaultActions:
- ForwardConfig:
TargetGroups:
- TargetGroupArn: !Ref 'OmeroserverTCP4064TargetGroup'
Type: forward
LoadBalancerArn: !If
- CreateLoadBalancer
- !Ref 'DockerexampleomeroLoadBalancer'
- !Ref 'ParameterLoadBalancerARN'
Port: 4064
Protocol: TCP
OmeroserverTCP4064TargetGroup:
Type: AWS::ElasticLoadBalancingV2::TargetGroup
Properties:
Port: 4064
Protocol: TCP
Tags:
- Key: com.docker.compose.project
Value: dockerexampleomero
TargetType: ip
VpcId: !Ref 'ParameterVPCId'
OmeroserverTaskDefinition:
Type: AWS::ECS::TaskDefinition
Properties:
ContainerDefinitions:
- Environment:
- Name: CONFIG_omero_db_host
Value: database
- Name: CONFIG_omero_db_user
Value: omero
- Name: CONFIG_omero_db_pass
Value: omero
- Name: CONFIG_omero_db_name
Value: omero
- Name: LOCALDOMAIN
Value: !Join
- ''
- - !Ref 'AWS::Region'
- .compute.internal
- ' dockerexampleomero.local'
- Name: ROOTPASS
Value: omero
Essential: true
Image: openmicroscopy/omero-server:latest
LinuxParameters: {}
LogConfiguration:
LogDriver: awslogs
Options:
awslogs-group: !Ref 'LogGroup'
awslogs-region: !Ref 'AWS::Region'
awslogs-stream-prefix: dockerexampleomero
Name: omeroserver
PortMappings:
- ContainerPort: 4063
HostPort: 4063
Protocol: tcp
- ContainerPort: 4064
HostPort: 4064
Protocol: tcp
Cpu: '2048'
Memory: '4096'
ExecutionRoleArn: !Ref 'OmeroserverTaskExecutionRole'
Family: dockerexampleomero-omeroserver
NetworkMode: awsvpc
RequiresCompatibilities:
- FARGATE
OmeroserverTaskExecutionRole:
Type: AWS::IAM::Role
Properties:
AssumeRolePolicyDocument:
Statement:
- Action:
- sts:AssumeRole
Effect: Allow
Principal:
Service: ecs-tasks.amazonaws.com
Version: '2012-10-17'
ManagedPolicyArns:
- arn:aws:iam::aws:policy/service-role/AmazonECSTaskExecutionRolePolicy
- arn:aws:iam::aws:policy/AmazonEC2ContainerRegistryReadOnly
OmerowebService:
Type: AWS::ECS::Service
DependsOn:
- OmerowebTCP4080Listener
Properties:
Cluster: !If
- CreateCluster
- !Ref 'Cluster'
- !Ref 'ParameterClusterName'
DeploymentConfiguration:
MaximumPercent: 200
MinimumHealthyPercent: 100
DeploymentController:
Type: ECS
DesiredCount: 1
LaunchType: FARGATE
LoadBalancers:
- ContainerName: omeroweb
ContainerPort: 4080
TargetGroupArn: !Ref 'OmerowebTCP4080TargetGroup'
NetworkConfiguration:
AwsvpcConfiguration:
AssignPublicIp: ENABLED
SecurityGroups:
- !Ref 'DockerexampleomeroOmeroNetwork'
Subnets:
- !Ref 'ParameterSubnet1Id'
- !Ref 'ParameterSubnet2Id'
PropagateTags: SERVICE
SchedulingStrategy: REPLICA
ServiceRegistries:
- RegistryArn: !GetAtt 'OmerowebServiceDiscoveryEntry.Arn'
Tags:
- Key: com.docker.compose.project
Value: dockerexampleomero
- Key: com.docker.compose.service
Value: omeroweb
TaskDefinition: !Ref 'OmerowebTaskDefinition'
OmerowebServiceDiscoveryEntry:
Type: AWS::ServiceDiscovery::Service
Properties:
Description: '"omeroweb" service discovery entry in Cloud Map'
DnsConfig:
DnsRecords:
- TTL: 60
Type: A
RoutingPolicy: MULTIVALUE
HealthCheckCustomConfig:
FailureThreshold: 1
Name: omeroweb
NamespaceId: !Ref 'CloudMap'
OmerowebTCP4080Listener:
Type: AWS::ElasticLoadBalancingV2::Listener
Properties:
DefaultActions:
- ForwardConfig:
TargetGroups:
- TargetGroupArn: !Ref 'OmerowebTCP4080TargetGroup'
Type: forward
LoadBalancerArn: !If
- CreateLoadBalancer
- !Ref 'DockerexampleomeroLoadBalancer'
- !Ref 'ParameterLoadBalancerARN'
Port: 4080
Protocol: TCP
OmerowebTCP4080TargetGroup:
Type: AWS::ElasticLoadBalancingV2::TargetGroup
Properties:
Port: 4080
Protocol: TCP
Tags:
- Key: com.docker.compose.project
Value: dockerexampleomero
TargetType: ip
VpcId: !Ref 'ParameterVPCId'
OmerowebTaskDefinition:
Type: AWS::ECS::TaskDefinition
Properties:
ContainerDefinitions:
- Environment:
- Name: OMEROHOST
Value: omeroserver
- Name: LOCALDOMAIN
Value: !Join
- ''
- - !Ref 'AWS::Region'
- .compute.internal
- ' dockerexampleomero.local'
Essential: true
Image: openmicroscopy/omero-web-standalone:latest
LinuxParameters: {}
LogConfiguration:
LogDriver: awslogs
Options:
awslogs-group: !Ref 'LogGroup'
awslogs-region: !Ref 'AWS::Region'
awslogs-stream-prefix: dockerexampleomero
Name: omeroweb
PortMappings:
- ContainerPort: 4080
HostPort: 4080
Protocol: tcp
Cpu: '2048'
Memory: '4096'
ExecutionRoleArn: !Ref 'OmerowebTaskExecutionRole'
Family: dockerexampleomero-omeroweb
NetworkMode: awsvpc
RequiresCompatibilities:
- FARGATE
OmerowebTaskExecutionRole:
Type: AWS::IAM::Role
Properties:
AssumeRolePolicyDocument:
Statement:
- Action:
- sts:AssumeRole
Effect: Allow
Principal:
Service: ecs-tasks.amazonaws.com
Version: '2012-10-17'
ManagedPolicyArns:
- arn:aws:iam::aws:policy/service-role/AmazonECSTaskExecutionRolePolicy
- arn:aws:iam::aws:policy/AmazonEC2ContainerRegistryReadOnly
Outputs:
DockerexampleomeroLoadBalancerDNSName:
Description: The DNSName of the DockerexampleomeroLoadBalancer
Value: !GetAtt DockerexampleomeroLoadBalancer.DNSName