-
Notifications
You must be signed in to change notification settings - Fork 0
/
ecs-service.yml
95 lines (92 loc) · 3.18 KB
/
ecs-service.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
AWSTemplateFormatVersion: '2010-09-09'
Description: Deploy a service on AWS Fargate, hosted in a public subnet.
Parameters:
StackName:
Type: String
Default: production
Description: The name of the parent Fargate networking stack that you created. Necessary
to locate and reference resources created by that stack.
ServiceName:
Type: String
Default: ipfs
Description: A name for the service
ImageUrl:
Type: String
Description: The url of a docker image that contains the application process that
will handle the traffic for this service
ContainerCpu:
Type: Number
Default: 256
Description: How much CPU to give the container. 1024 is 1 CPU
ContainerMemory:
Type: Number
Default: 512
Description: How much memory in megabytes to give the container
DesiredCount:
Type: Number
Default: 2
Description: How many copies of the service task to run
Resources:
# The task definition. This is a simple metadata description of what
# container to run, and what resource requirements it has.
TaskDefinition:
Type: AWS::ECS::TaskDefinition
Properties:
Family: !Ref 'ServiceName'
Cpu: !Ref 'ContainerCpu'
Memory: !Ref 'ContainerMemory'
NetworkMode: host
RuntimePlatform:
OperatingSystemFamily: LINUX
ExecutionRoleArn:
Fn::ImportValue:
!Join [':', [!Ref 'StackName', 'ECSTaskExecutionRole']]
TaskRoleArn:
Fn::ImportValue:
!Join [':', [!Ref 'StackName', 'ECSTaskRole']]
Volumes:
- Name: EfsVolume
EFSVolumeConfiguration:
FilesystemId:
Fn::ImportValue:
!Join [':', [!Ref 'StackName', 'EFSFileSystem']]
AuthorizationConfig:
IAM: ENABLED
TransitEncryption: ENABLED
RootDirectory: "/.ipfs"
ContainerDefinitions:
- Name: !Ref 'ServiceName'
Cpu: !Ref 'ContainerCpu'
Memory: !Ref 'ContainerMemory'
Image: !Ref 'ImageUrl'
MountPoints:
- SourceVolume: "EfsVolume"
ContainerPath: "/root/.jsipfs"
Interactive: true
LogConfiguration:
LogDriver: awslogs
Options:
awslogs-region: us-east-2
awslogs-group: !Sub 'service-${ServiceName}'
awslogs-create-group: true
awslogs-stream-prefix: !Ref 'ServiceName'
PortMappings:
- ContainerPort: 4002
- ContainerPort: 8081
- ContainerPort: 5002
- ContainerPort: 9090
# The service. The service is a resource which allows you to run multiple
# copies of a type of task, and gather up their logs and metrics, as well
# as monitor the number of running tasks and replace any that have crashed
Service:
Type: AWS::ECS::Service
Properties:
ServiceName: !Ref 'ServiceName'
Cluster:
Fn::ImportValue:
!Join [':', [!Ref 'StackName', 'ClusterName']]
DeploymentConfiguration:
MaximumPercent: 100
MinimumHealthyPercent: 0
DesiredCount: !Ref 'DesiredCount'
TaskDefinition: !Ref 'TaskDefinition'