-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtemplate.yaml
66 lines (61 loc) · 2.22 KB
/
template.yaml
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
Transform: AWS::Serverless-2016-10-31
Description: Orphaned Log Groups Collector deletes AWS Lambda and Amazon RDS related log groups not associated with any resources in the AWS Account.
Metadata:
AWS::ServerlessRepo::Application:
Name: orphaned-log-groups-collector
Description: Orphaned Log Groups Collector deletes AWS Lambda and Amazon RDS related log groups not associated with any resources in the AWS Account.
Author: Michal Gorski
SpdxLicenseId: Apache-2.0
LicenseUrl: LICENSE
ReadmeUrl: README.md
Labels: [ 'lambda','rds','cloudwatch','cron' ]
HomePageUrl: https://github.com/mgorski-mg/aws-orphaned-log-groups-collector
SemanticVersion: 2.1.1
SourceCodeUrl: https://github.com/mgorski-mg/aws-orphaned-log-groups-collector
Parameters:
SchedulerCronParameter:
Type: String
Description: Enter scheduler cron expression. Default is cron(0 0 1 * ? *).
Default: cron(0 0 1 * ? *)
SchedulerEnabledParameter:
Type: String
Description: Enable scheduler. Default is ENABLED.
Default: ENABLED
AllowedValues: [ ENABLED, DISABLED ]
Resources:
OrphanedLogGroupsCollector:
Type: AWS::Serverless::Function
Properties:
Description: Delete orphaned log groups
CodeUri: code/
Handler: handler.lambda_handler
Runtime: python3.9
Timeout: 900
MemorySize: 128
Tracing: Active
Architectures:
- arm64
Events:
Schedule:
Type: Schedule
Properties:
State: !Ref SchedulerEnabledParameter
Schedule: !Ref SchedulerCronParameter
Input: '{"dry_run": false}'
Policies:
- AWSLambdaBasicExecutionRole
- Version: 2012-10-17
Statement:
- Effect: Allow
Action:
- ec2:DescribeRegions
- logs:DescribeLogGroups
- logs:DeleteLogGroup
- lambda:ListFunctions
- rds:DescribeDBClusters
Resource: '*'
OrphanedLogGroupsCollectorLogGroup:
Type: AWS::Logs::LogGroup
Properties:
LogGroupName: !Sub /aws/lambda/${OrphanedLogGroupsCollector}
RetentionInDays: 180