This repository has been archived by the owner on Aug 24, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
serverless.yml
executable file
·69 lines (63 loc) · 1.94 KB
/
serverless.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
service: restartFargateServices
custom:
snsTopic: "${self:service}-${self:provider.stage}-fargate-memory-alarms"
snsTopicArn: { "Fn::Join" : ["", ["arn:aws:sns:${self:provider.region}:", { "Ref" : "AWS::AccountId" }, ":${self:custom.snsTopic}" ] ] }
myEnvironment:
CLUSTER_NAME:
production: "prod-railsapp"
staging: "staging-railsapp"
provider:
name: aws
runtime: ruby2.5
stage: ${opt:stage, 'staging'}
region: eu-west-1
iamRoleStatements:
- Effect: Allow
Action:
- ecs:UpdateService
Resource: '*'
functions:
restartFargateServices:
handler: handler.restart_service
events:
- sns: ${self:custom.snsTopic}
resources:
Resources:
ApiMemoryUsageAlarm:
Type: AWS::CloudWatch::Alarm
Properties:
ActionsEnabled: true
AlarmActions:
- ${self:custom.snsTopicArn}
AlarmName: ${self:service}:${self:provider.stage}:ApiMemoryUsageAlarm
ComparisonOperator: GreaterThanOrEqualToThreshold
Dimensions:
- Name: ClusterName
Value: ${self:custom.myEnvironment.CLUSTER_NAME.${self:provider.stage}}
- Name: ServiceName
Value: api
EvaluationPeriods: 2
MetricName: MemoryUtilization
Namespace: AWS/ECS
Period: 120
Statistic: Maximum
Threshold: 85.0
AdminMemoryUsageAlarm:
Type: AWS::CloudWatch::Alarm
Properties:
ActionsEnabled: true
AlarmActions:
- ${self:custom.snsTopicArn}
AlarmName: ${self:service}:${self:provider.stage}:AdminMemoryUsageAlarm
ComparisonOperator: GreaterThanOrEqualToThreshold
Dimensions:
- Name: ClusterName
Value: ${self:custom.myEnvironment.CLUSTER_NAME.${self:provider.stage}}
- Name: ServiceName
Value: admin
EvaluationPeriods: 2
MetricName: MemoryUtilization
Namespace: AWS/ECS
Period: 120
Statistic: Maximum
Threshold: 85.0