-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathserverless.yml
121 lines (115 loc) · 4.44 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
frameworkVersion: "^3.43.1"
service: serverless-provisioned-memory-report
useDotenv: true
plugins:
- serverless-webpack
- serverless-step-functions
- serverless-iam-roles-per-function
provider:
name: aws
runtime: nodejs22.x
profile: default
region: ${opt:region, 'eu-west-1'}
logRetentionInDays: 30
memorySize: 256
versionFunctions: false
deploymentMethod: direct
architecture: arm64
environment:
CLOUDWATCH_LOGS_PARALLEL_QUERIES: 30
custom:
webpack:
includeModules: true
excludeRegex: 'node_modules/@aws-sdk'
packager: yarn
packagerOptions:
ignoreScripts: true
serverless-iam-roles-per-function:
defaultInherit: true
functions:
listLambdas:
handler: functions/listLambdas.handler
description: Check memory usage for all Lambdas from the current AWS account
iamRoleStatementsName: ${env:DEVELOPER, '20mn'}RoleLambdaProvisionedListLambdas
iamRoleStatements:
-
Effect: 'Allow'
Action:
- lambda:ListFunctions
Resource: '*'
startQuery:
handler: functions/startQuery.handler
description: Check memory usage for all Lambdas from the current AWS account
iamRoleStatementsName: ${env:DEVELOPER, '20mn'}RoleLambdaProvisionedStartQuery
iamRoleStatements:
-
Effect: 'Allow'
Action:
- logs:StartQuery
Resource: '*'
extractQueryResult:
handler: functions/extractQueryResult.handler
description: Check memory usage for all Lambdas from the current AWS account
iamRoleStatementsName: ${env:DEVELOPER, '20mn'}RoleLambdaProvisionedExtractQueryResult
iamRoleStatements:
-
Effect: 'Allow'
Action:
- logs:GetQueryResults
Resource: '*'
reportToSlack:
handler: functions/reportToSlack.handler
description: Check memory usage for all Lambdas from the current AWS account
environment:
SLACK_WEBHOOK_URL: ${env:SLACK_WEBHOOK_URL}
stepFunctions:
stateMachines:
CheckProvisionedMemory:
name: CheckProvisionedMemory
definition:
Comment: A step function to check provisioned memory on Lambda
StartAt: ListLambdas
States:
ListLambdas:
Type: Task
Resource:
Fn::GetAtt: [listLambdas, Arn]
Next: StartQueries
StartQueries:
Type: Map
ItemsPath: "$.functions"
ResultPath: "$.functions"
Iterator:
StartAt: StartQuery
States:
StartQuery:
Type: Task
Resource:
Fn::GetAtt: [startQuery, Arn]
Next: WaitForQueryToFinish
WaitForQueryToFinish:
Type: Wait
Seconds: 10
Next: ExtractQueryResult
ExtractQueryResult:
Type: Task
Resource:
Fn::GetAtt: [extractQueryResult, Arn]
Next: IsItFinish
IsItFinish:
Type: Choice
Choices:
-
Variable: "$.running"
BooleanEquals: true
Next: WaitForQueryToFinish
Default: QueryDone
QueryDone:
Type: Pass
End: true
Next: ReportToSlack
ReportToSlack:
Type: Task
Resource:
Fn::GetAtt: [reportToSlack, Arn]
End: true