This repository has been archived by the owner on Sep 21, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathserverless.yml
79 lines (69 loc) · 2.04 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
service: logstream-cleanup
plugins:
- serverless-esbuild
configValidationMode: error
custom:
# Define how often the clean up should run
cleanupRate: rate(1 day)
# Configure how many days logs of this job should be saved
logRetentionInDays: 5
# Configure how many hours empty log streams should be kept after creation
keepNewEmptyStreamsInHours: 2
esbuild:
bundle: true
minify: true
sourcemap: true
package:
individually: true
provider:
architecture: arm64
deploymentMethod: direct
name: aws
stackName: logstream-cleanup
runtime: nodejs18.x
versionFunctions: false
region: ${opt:region, 'us-east-1'}
logRetentionInDays: ${self:custom.logRetentionInDays}
iam:
role:
statements:
- Effect: Allow
Action:
- lambda:InvokeFunction
- lambda:InvokeAsync
Resource: '*'
- Effect: Allow
Action:
- logs:DescribeLogGroups
Resource: 'arn:aws:logs:*:*:log-group:*'
- Effect: Allow
Action:
- logs:DeleteLogStream
- logs:DescribeLogStreams
Resource: 'arn:aws:logs:*:*:log-group:/aws/lambda/*'
environment:
AWS_NODEJS_CONNECTION_REUSE_ENABLED: 1
NODE_OPTIONS: --enable-source-maps
STAGE: ${sls:stage}
keepStreams: ${self:custom.keepNewEmptyStreamsInHours}
functions:
logStreamsCleanupDispatch:
name: logstream-cleanup-dispatch
description: Entry point for scheduled logstream cleanup
handler: src/handler.logStreamsCleanupDispatch
timeout: 900
events:
- schedule:
rate: ${self:custom.cleanupRate}
enabled: true
name: logStreamsCleanup
logStreamsCleanupGroup:
name: logstream-cleanup-group-handler
description: Handler for a single group
handler: src/handler.logStreamsCleanupGroupHandler
timeout: 900
logStreamsCleanupStreams:
name: logstream-cleanup-streams-handler
description: Handler for a group of single streams
handler: src/handler.logStreamsCleanupStreamsHandler
timeout: 900