This repository has been archived by the owner on Jan 17, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathserverless.yml
160 lines (153 loc) · 4.74 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
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
service: aqts-capture-error-handler
provider:
name: aws
rolePermissionsBoundary:
Fn::Sub:
- "arn:aws:iam::${accountId}:policy/csr-Developer-Permissions-Boundary"
- accountId:
Ref: "AWS::AccountId"
vpc: ${self:custom.vpc}
region: ${opt:region, 'us-west-2'}
stage: ${opt:stage, 'TEST'}
runtime: python3.8
memorySize: 128
timeout: 45
logRetentionInDays: 90
deploymentBucket:
name: ${opt:bucket, iow-cloud-applications}
stackTags:
"wma:project_id": "aqtscapture"
"wma:subSystem": "aqtscapture"
"wma:application_id": "Aquarius TS Capture Error Handler"
"wma:contact": "Andrew Yan [email protected]"
"wma:role": etl
"wma:system": NWIS
"wma:environment": ${self:provider.stage}
"wma:taggingVersion": 0.0.1
"wma:costCenter": TBD
"wma:organization": IOW
"displayName": "Error Handler"
commitIdentifier: ${git:sha1}
custom:
exportGitVariables: false
vpc:
securityGroupIds: ${ssm:/iow/retriever-capture/${self:provider.stage}/securityGroupIds~split}
subnetIds: ${ssm:/iow/aws/vpc/${self:provider.stage}/subnetIds~split}
esLogs:
endpoint: ${ssm:/iow/aws/vpc/${self:provider.stage}/elasticsearchEndpoint}
index: ${self:service}
retentionInDays: 90
filterPattern: "?WARNING ?ERROR ?CRITICAL"
prune:
automatic: true
number: 3
mailingList: ${ssm:/aws/reference/secretsmanager/AQTS-CAPTURE-MAILING-LISTS~true}
functions:
aqtsErrorHandler:
handler: persist_error.handler.lambda_handler
role:
Fn::Sub:
- arn:aws:iam::${accountId}:role/csr-Lambda-Role
- accountId:
Ref: AWS::AccountId
onError:
Ref: snsTopic
reservedConcurrency: 290
environment:
AWS_SQS_QUEUE_URL:
Ref: errorPersistQueue
AWS_TERMINAL_QUEUE_URL:
Ref: terminalErrorsQueue
AWS_SNS_ARN:
Ref: snsTopic
AWS_DEPLOYMENT_REGION: ${self:provider.region}
DEPLOY_STAGE: ${self:provider.stage}
MAX_RETRIES: 6
LOG_LEVEL: WARNING
resources:
Resources:
snsTopic:
Type: AWS::SNS::Topic
Properties:
DisplayName: ${self:service}-${self:provider.stage}-topic
TopicName: ${self:service}-${self:provider.stage}-topic
Subscription:
- Protocol: email
Endpoint: ${self:custom.mailingList.TERMINAL_ERRORS_GROUP}
invocationAlarm:
Type: AWS::CloudWatch::Alarm
Properties:
AlarmName: ${self:service}-${self:provider.stage}-invocation-alarm
AlarmDescription: Notify when invocations exceeds the specified threshold
Namespace: 'AWS/Lambda'
Dimensions:
- Name: FunctionName
Value:
Ref: AqtsErrorHandlerLambdaFunction
MetricName: Invocations
Statistic: Sum
ComparisonOperator: GreaterThanOrEqualToThreshold
Threshold: 1000
Period: 60
EvaluationPeriods: 5
AlarmActions:
- Ref: snsTopic
concurrencyAlarm:
Type: AWS::CloudWatch::Alarm
Properties:
AlarmName: ${self:service}-${self:provider.stage}-concurrency-alarm
AlarmDescription: Notify when concurrency exceeds the specified threshold
Namespace: 'AWS/Lambda'
Dimensions:
- Name: FunctionName
Value:
Ref: AqtsErrorHandlerLambdaFunction
MetricName: ConcurrentExecutions
Statistic: Maximum
ComparisonOperator: GreaterThanOrEqualToThreshold
Threshold: 150
Period: 60
EvaluationPeriods: 1
AlarmActions:
- Ref: snsTopic
errorAlarm:
Type: AWS::CloudWatch::Alarm
Properties:
AlarmName: ${self:service}-${self:provider.stage}-error-alarm
AlarmDescription: Notify when number of errors exceeds the specified threshold
Namespace: 'AWS/Lambda'
Dimensions:
- Name: FunctionName
Value:
Ref: AqtsErrorHandlerLambdaFunction
MetricName: Errors
Statistic: Sum
ComparisonOperator: GreaterThanOrEqualToThreshold
Threshold: 10
Period: 60
EvaluationPeriods: 1
AlarmActions:
- Ref: snsTopic
errorPersistQueue:
Type: AWS::SQS::Queue
Properties:
QueueName: aqts-capture-error-queue-${self:provider.stage}
MessageRetentionPeriod: 1209600
terminalErrorsQueue:
Type: AWS::SQS::Queue
Properties:
QueueName: aqts-capture-terminal-errors-queue-${self:provider.stage}
MessageRetentionPeriod: 345600
plugins:
- serverless-plugin-git-variables
- serverless-python-requirements
- serverless-es-logs
- serverless-prune-plugin
package:
exclude:
- node_modules/**
- Dockerfile
- .dockerignore
- Jenkinsfile
- package.json
- package-lock.json