forked from lumigo-io/SAR-Lambda-Janitor
-
Notifications
You must be signed in to change notification settings - Fork 0
/
template.yml
54 lines (50 loc) · 1.43 KB
/
template.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
AWSTemplateFormatVersion: 2010-09-09
Transform: AWS::Serverless-2016-10-31
Metadata:
AWS::ServerlessRepo::Application:
Name: lambda-janitor
Description: Cron job for deleting old, unused versions of Lambda functions to clean up storage space
Author: Lumigo
SpdxLicenseId: MIT
LicenseUrl: LICENSE.txt
ReadmeUrl: README.md
Labels: ['lambda', 'cron']
HomePageUrl: https://github.com/lumigo/SAR-Lambda-Janitor
SemanticVersion: 1.5.0
SourceCodeUrl: https://github.com/lumigo/SAR-Lambda-Janitor
Resources:
Clean:
Type: AWS::Serverless::Function
Properties:
Handler: functions/clean.handler
Runtime: nodejs10.x
Timeout: 900
Environment:
Variables:
LOG_LEVEL: INFO
VERSIONS_TO_KEEP:
Ref: VersionsToKeep
AWS_NODEJS_CONNECTION_REUSE_ENABLED: 1
Policies:
- Statement:
Effect: Allow
Action:
- lambda:DeleteFunction
- lambda:List*
Resource: "*"
Events:
CleanScheduledEvent:
Type: Schedule
Properties:
Schedule: rate(1 hour)
LogGroup:
Type: AWS::Logs::LogGroup
Properties:
LogGroupName: !Sub /aws/lambda/${Clean}
Parameters:
VersionsToKeep:
Type: Number
Description: >-
How many versions to keep, even if they are not aliased.
Default: 3
MinValue: 0 # don't keep anything except $Latest