-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcloudwatch-metric-filters.tf
131 lines (110 loc) · 6.42 KB
/
cloudwatch-metric-filters.tf
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
122
123
124
125
126
127
128
129
130
131
resource "aws_cloudwatch_log_metric_filter" "S3BucketActivity" {
name = "S3BucketActivity"
pattern = "{ ($.eventSource = s3.amazonaws.com) && (($.eventName = PutBucketAcl) || ($.eventName = PutBucketPolicy) || ($.eventName = PutBucketCors) || ($.eventName = PutBucketLifecycle) || ($.eventName = PutBucketReplication) || ($.eventName = DeleteBucketPolicy) || ($.eventName = DeleteBucketCors) || ($.eventName = DeleteBucketLifecycle) || ($.eventName = DeleteBucketReplication)) }"
log_group_name = "${aws_cloudwatch_log_group.log_group_default.name}"
metric_transformation {
name = "S3BucketActivityEventCount"
namespace = "CloudTrailMetrics"
value = "1"
}
}
resource "aws_cloudwatch_log_metric_filter" "SecurityGroupChangesMetricFilter" {
name = "SecurityGroupChangesMetricFilter"
pattern = "{ ($.eventName = AuthorizeSecurityGroupIngress) || ($.eventName = AuthorizeSecurityGroupEgress) || ($.eventName = RevokeSecurityGroupIngress) || ($.eventName = RevokeSecurityGroupEgress) || ($.eventName = CreateSecurityGroup) || ($.eventName = DeleteSecurityGroup) }"
log_group_name = "${aws_cloudwatch_log_group.log_group_default.name}"
metric_transformation {
name = "SecurityGroupEventCount"
namespace = "CloudTrailMetrics"
value = "1"
}
}
resource "aws_cloudwatch_log_metric_filter" "NetworkAclChangesMetricFilter" {
name = "NetworkAclChangesMetricFilter"
pattern = "{ ($.eventName = CreateNetworkAcl) || ($.eventName = CreateNetworkAclEntry) || ($.eventName = DeleteNetworkAcl) || ($.eventName = DeleteNetworkAclEntry) || ($.eventName = ReplaceNetworkAclEntry) || ($.eventName = ReplaceNetworkAclAssociation) }"
log_group_name = "${aws_cloudwatch_log_group.log_group_default.name}"
metric_transformation {
name = "NetworkAclEventCount"
namespace = "CloudTrailMetrics"
value = "1"
}
}
resource "aws_cloudwatch_log_metric_filter" "GatewayChangesMetricFilter" {
name = "GatewayChangesMetricFilter"
pattern = "{ ($.eventName = CreateCustomerGateway) || ($.eventName = DeleteCustomerGateway) || ($.eventName = AttachInternetGateway) || ($.eventName = CreateInternetGateway) || ($.eventName = DeleteInternetGateway) || ($.eventName = DetachInternetGateway) }"
log_group_name = "${aws_cloudwatch_log_group.log_group_default.name}"
metric_transformation {
name = "GatewayEventCount"
namespace = "CloudTrailMetrics"
value = "1"
}
}
resource "aws_cloudwatch_log_metric_filter" "VpcChangesMetricFilter" {
name = "VpcChangesMetricFilter"
pattern = "{ ($.eventName = CreateVpc) || ($.eventName = DeleteVpc) || ($.eventName = ModifyVpcAttribute) || ($.eventName = AcceptVpcPeeringConnection) || ($.eventName = CreateVpcPeeringConnection) || ($.eventName = DeleteVpcPeeringConnection) || ($.eventName = RejectVpcPeeringConnection) || ($.eventName = AttachClassicLinkVpc) || ($.eventName = DetachClassicLinkVpc) || ($.eventName = DisableVpcClassicLink) || ($.eventName = EnableVpcClassicLink) }"
log_group_name = "${aws_cloudwatch_log_group.log_group_default.name}"
metric_transformation {
name = "VpcEventCount"
namespace = "CloudTrailMetrics"
value = "1"
}
}
resource "aws_cloudwatch_log_metric_filter" "EC2InstanceChangesMetricFilter" {
name = "EC2InstanceChangesMetricFilter"
pattern = "{ ($.eventName = RunInstances) || ($.eventName = RebootInstances) || ($.eventName = StartInstances) || ($.eventName = StopInstances) || ($.eventName = TerminateInstances) }"
log_group_name = "${aws_cloudwatch_log_group.log_group_default.name}"
metric_transformation {
name = "EC2InstanceEventCount"
namespace = "CloudTrailMetrics"
value = "1"
}
}
resource "aws_cloudwatch_log_metric_filter" "EC2LargeInstanceChangesMetricFilter" {
name = "EC2LargeInstanceChangesMetricFilter"
pattern = "{ ($.eventName = RunInstances) && (($.requestParameters.instanceType = *.8xlarge) || ($.requestParameters.instanceType = *.4xlarge)) }"
log_group_name = "${aws_cloudwatch_log_group.log_group_default.name}"
metric_transformation {
name = "EC2LargeInstanceEventCount"
namespace = "CloudTrailMetrics"
value = "1"
}
}
resource "aws_cloudwatch_log_metric_filter" "CloudTrailChangesMetricFilter" {
name = "CloudTrailChangesMetricFilter"
pattern = "{ ($.eventName = CreateTrail) || ($.eventName = UpdateTrail) || ($.eventName = DeleteTrail) || ($.eventName = StartLogging) || ($.eventName = StopLogging) }"
log_group_name = "${aws_cloudwatch_log_group.log_group_default.name}"
metric_transformation {
name = "CloudTrailEventCount"
namespace = "CloudTrailMetrics"
value = "1"
}
}
resource "aws_cloudwatch_log_metric_filter" "ConsoleSignInFailuresMetricFilter" {
name = "ConsoleSignInFailuresMetricFilter"
pattern = "{ ($.eventName = ConsoleLogin) && ($.errorMessage = \"Failed authentication\") }"
log_group_name = "${aws_cloudwatch_log_group.log_group_default.name}"
metric_transformation {
name = "ConsoleSignInFailureCount"
namespace = "CloudTrailMetrics"
value = "1"
}
}
resource "aws_cloudwatch_log_metric_filter" "AuthorizationFailuresMetricFilter" {
name = "AuthorizationFailuresMetricFilter"
pattern = "{ ($.errorCode = \"*UnauthorizedOperation\") || ($.errorCode = \"AccessDenied*\") }"
log_group_name = "${aws_cloudwatch_log_group.log_group_default.name}"
metric_transformation {
name = "AuthorizationFailureCount"
namespace = "CloudTrailMetrics"
value = "1"
}
}
resource "aws_cloudwatch_log_metric_filter" "IAMPolicyChangesMetricFilter" {
name = "IAMPolicyChangesMetricFilter"
pattern = "{($.eventName=DeleteGroupPolicy)||($.eventName=DeleteRolePolicy)||($.eventName=DeleteUserPolicy)||($.eventName=PutGroupPolicy)||($.eventName=PutRolePolicy)||($.eventName=PutUserPolicy)||($.eventName=CreatePolicy)||($.eventName=DeletePolicy)||($.eventName=CreatePolicyVersion)||($.eventName=DeletePolicyVersion)||($.eventName=AttachRolePolicy)||($.eventName=DetachRolePolicy)||($.eventName=AttachUserPolicy)||($.eventName=DetachUserPolicy)||($.eventName=AttachGroupPolicy)||($.eventName=DetachGroupPolicy)}"
log_group_name = "${aws_cloudwatch_log_group.log_group_default.name}"
metric_transformation {
name = "IAMPolicyEventCount"
namespace = "CloudTrailMetrics"
value = "1"
}
}