-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathtest-service.yaml
193 lines (167 loc) · 4.59 KB
/
test-service.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
Description: >
Create ECS Service for Deployment on ECS.
Parameters:
DesiredCount:
Type: Number
Default: 0
VpcId:
Type: AWS::EC2::VPC::Id
Cluster:
Type: String
LoadBalancer:
Type: String
Repository:
Type: String
Tag:
Type: String
Default: latest
Port:
Type: Number
Identifier:
Type: String
IsProduction:
Type: String
DBAddress:
Type: String
DBPassword:
Type: String
HostedZoneName:
Type: String
Hostname:
Type: String
CloudwatchLogsGroup:
Type: String
certificateArn:
Type: String
clientId:
Type: String
clientSecret:
Type: String
lexBotName:
Type: String
Resources:
LoadBalancerListener:
Type: AWS::ElasticLoadBalancingV2::Listener
Properties:
LoadBalancerArn: !Ref LoadBalancer
Certificates:
- CertificateArn: !Ref certificateArn
Port: !Ref Port
Protocol: HTTPS
DefaultActions:
- Type: forward
TargetGroupArn: !Ref TargetGroup
TargetGroup:
Type: AWS::ElasticLoadBalancingV2::TargetGroup
Properties:
VpcId: !Ref VpcId
Port: !Ref Port
Protocol: HTTP
Matcher:
HttpCode: 302
HealthCheckIntervalSeconds: 10
HealthCheckPath: /login
HealthCheckProtocol: HTTP
HealthCheckTimeoutSeconds: 5
HealthyThresholdCount: 2
TargetGroupAttributes:
- Key: deregistration_delay.timeout_seconds
Value: 20
Tags:
- Key: Identifier
Value: !Ref Identifier
- Key: Image
Value: !Ref Tag
- Key: IsProduction
Value: !Ref IsProduction
ListenerRule:
Type: AWS::ElasticLoadBalancingV2::ListenerRule
Properties:
Actions:
- Type: forward
TargetGroupArn: !Ref TargetGroup
Conditions:
- Field: path-pattern
Values:
- "*"
ListenerArn: !Ref LoadBalancerListener
Priority: 1
ECSServiceRole:
Type: AWS::IAM::Role
Properties:
#RoleName: !Sub ecs-service-${AWS::StackName}
Path: /
AssumeRolePolicyDocument: |
{
"Statement": [{
"Effect": "Allow",
"Principal": { "Service": [ "ecs.amazonaws.com" ]},
"Action": [ "sts:AssumeRole" ]
}]
}
Policies:
- PolicyName: ecs-service-role
PolicyDocument:
Version: 2012-10-17
Statement:
- Effect: Allow
Resource: "*"
Action:
- ec2:*
- ecs:*
- elasticloadbalancing:DeregisterInstancesFromLoadBalancer
- elasticloadbalancing:DeregisterTargets
- elasticloadbalancing:RegisterTargets
- elasticloadbalancing:Describe*
- elasticloadbalancing:RegisterInstancesWithLoadBalancer
- logs:CreateLogStream
- logs:PutLogEvents
- lex:*
Service:
Type: AWS::ECS::Service
Properties:
Cluster: !Ref Cluster
Role: !Ref ECSServiceRole
DesiredCount: !Ref DesiredCount
TaskDefinition: !Ref TaskDefinition
LoadBalancers:
- ContainerName: !Ref Hostname
ContainerPort: !Ref Port
TargetGroupArn: !Ref TargetGroup
TaskDefinition:
Type: AWS::ECS::TaskDefinition
Properties:
#Family: !Sub ${AWS::StackName}-simple-app
ContainerDefinitions:
- Name: !Ref Hostname
Image: !Sub ${AWS::AccountId}.dkr.ecr.${AWS::Region}.amazonaws.com/${Repository}:${Tag}
Essential: true
Memory: 64
PortMappings:
- ContainerPort: !Ref Port
Environment:
- Name: Tag
Value: !Ref Tag
LogConfiguration:
LogDriver: awslogs
Options:
awslogs-group: !Ref CloudwatchLogsGroup
awslogs-region: !Ref AWS::Region
awslogs-stream-prefix: !Ref Hostname
Environment:
- Name: PORT
Value: !Ref Port
- Name: clientId
Value: !Sub "${clientId}"
- Name: clientSecret
Value: !Sub "${clientSecret}"
- Name: oauthRedirectUri
Value: !Sub https://${Hostname}.${HostedZoneName}/oauth
- Name: studio_token
Value: studiotokenexamplecharacters
- Name: DBconnection
Value: !Ref DBAddress
- Name: DBpassword
Value: !Ref DBPassword
- Name: lex_bot_name
Value: !Ref lexBotName