/
cloudwatch.sp
52 lines (44 loc) · 1.57 KB
/
cloudwatch.sp
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
variable "cloudwatch_log_stream_age_max_days" {
type = number
description = "The maximum number of days log streams are allowed without any log event written to them."
default = 90
}
locals {
cloudwatch_common_tags = merge(local.aws_thrifty_common_tags, {
service = "AWS/CloudWatch"
})
}
benchmark "cloudwatch" {
title = "CloudWatch Checks"
description = "Thrifty developers actively manage the retention of their Cloudtrail logs."
documentation = file("./controls/docs/cloudwatch.md")
children = [
control.cw_log_group_retention,
control.cw_log_stream_unused
]
tags = merge(local.cloudwatch_common_tags, {
type = "Benchmark"
})
}
control "cw_log_group_retention" {
title = "CloudWatch Log Groups retention should be enabled"
description = "All log groups should have a defined retention configuration."
sql = query.cw_log_group_without_retention.sql
severity = "low"
tags = merge(local.cloudwatch_common_tags, {
class = "managed"
})
}
control "cw_log_stream_unused" {
title = "Unused log streams should be removed if not required"
description = "Unnecessary log streams should be deleted for storage cost savings."
sql = query.stale_cw_log_stream.sql
severity = "low"
param "cloudwatch_log_stream_age_max_days" {
description = "The maximum number of days log streams are allowed without any log event written to them."
default = var.cloudwatch_log_stream_age_max_days
}
tags = merge(local.cloudwatch_common_tags, {
class = "unused"
})
}