Skip to content

Commit 0c4ae2d

Browse files
committed
add unit varibles
1 parent 442ce40 commit 0c4ae2d

File tree

4 files changed

+32
-8
lines changed

4 files changed

+32
-8
lines changed

main.tf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ module "alarm" {
5151
route_table_changes = var.route_table_changes
5252
vpc_changes = var.vpc_changes
5353
alarm_namespace = var.alarm_namespace
54+
unit = var.unit
5455

5556
cloudtrail_log_group_name = module.cloudtrail.log_group_name
5657
variables = {

modules/alarm/main.tf

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,7 @@ resource "aws_cloudwatch_metric_alarm" "unauthorized_api_calls" {
110110
metric_name = join("", aws_cloudwatch_log_metric_filter.unauthorized_api_calls.*.id)
111111
namespace = var.alarm_namespace
112112
period = "300"
113+
unit = var.unit
113114
statistic = "Sum"
114115
threshold = "1"
115116
alarm_description = "Monitoring unauthorized API calls will help reveal application errors and may reduce time to detect malicious activity."
@@ -147,6 +148,7 @@ resource "aws_cloudwatch_metric_alarm" "no_mfa_console_signin" {
147148
metric_name = join("", aws_cloudwatch_log_metric_filter.no_mfa_console_signin.*.id)
148149
namespace = var.alarm_namespace
149150
period = "300"
151+
unit = var.unit
150152
statistic = "Sum"
151153
threshold = "1"
152154
alarm_description = "Monitoring for single-factor console logins will increase visibility into accounts that are not protected by MFA."
@@ -184,6 +186,7 @@ resource "aws_cloudwatch_metric_alarm" "root_usage" {
184186
metric_name = join("", aws_cloudwatch_log_metric_filter.root_usage.*.id)
185187
namespace = var.alarm_namespace
186188
period = "300"
189+
unit = var.unit
187190
statistic = "Sum"
188191
threshold = "1"
189192
alarm_description = "Monitoring for root account logins will provide visibility into the use of a fully privileged account and an opportunity to reduce the use of it."
@@ -221,6 +224,7 @@ resource "aws_cloudwatch_metric_alarm" "iam_changes" {
221224
metric_name = join("", aws_cloudwatch_log_metric_filter.iam_changes.*.id)
222225
namespace = var.alarm_namespace
223226
period = "300"
227+
unit = var.unit
224228
statistic = "Sum"
225229
threshold = "1"
226230
alarm_description = "Monitoring changes to IAM policies will help ensure authentication and authorization controls remain intact."
@@ -258,6 +262,7 @@ resource "aws_cloudwatch_metric_alarm" "cloudtrail_cfg_changes" {
258262
metric_name = join("", aws_cloudwatch_log_metric_filter.cloudtrail_cfg_changes.*.id)
259263
namespace = var.alarm_namespace
260264
period = "300"
265+
unit = var.unit
261266
statistic = "Sum"
262267
threshold = "1"
263268
alarm_description = "Monitoring changes to CloudTrail's configuration will help ensure sustained visibility to activities performed in the AWS account."
@@ -296,6 +301,7 @@ resource "aws_cloudwatch_metric_alarm" "console_signin_failures" {
296301
metric_name = join("", aws_cloudwatch_log_metric_filter.console_signin_failures.*.id)
297302
namespace = var.alarm_namespace
298303
period = "300"
304+
unit = var.unit
299305
statistic = "Sum"
300306
threshold = "1"
301307
alarm_description = "Monitoring failed console logins may decrease lead time to detect an attempt to brute force a credential, which may provide an indicator, such as source IP, that can be used in other event correlation."
@@ -333,6 +339,7 @@ resource "aws_cloudwatch_metric_alarm" "disable_or_delete_cmk" {
333339
metric_name = join("", aws_cloudwatch_log_metric_filter.disable_or_delete_cmk.*.id)
334340
namespace = var.alarm_namespace
335341
period = "300"
342+
unit = var.unit
336343
statistic = "Sum"
337344
threshold = "1"
338345
alarm_description = "Monitoring failed console logins may decrease lead time to detect an attempt to brute force a credential, which may provide an indicator, such as source IP, that can be used in other event correlation."
@@ -370,6 +377,7 @@ resource "aws_cloudwatch_metric_alarm" "s3_bucket_policy_changes" {
370377
metric_name = join("", aws_cloudwatch_log_metric_filter.s3_bucket_policy_changes.*.id)
371378
namespace = var.alarm_namespace
372379
period = "300"
380+
unit = var.unit
373381
statistic = "Sum"
374382
threshold = "1"
375383
alarm_description = "Monitoring changes to S3 bucket policies may reduce time to detect and correct permissive policies on sensitive S3 buckets."
@@ -407,6 +415,7 @@ resource "aws_cloudwatch_metric_alarm" "security_group_changes" {
407415
metric_name = join("", aws_cloudwatch_log_metric_filter.security_group_changes.*.id)
408416
namespace = var.alarm_namespace
409417
period = "300"
418+
unit = var.unit
410419
statistic = "Sum"
411420
threshold = "1"
412421
alarm_description = "Monitoring changes to security group will help ensure that resources and services are not unintentionally exposed."
@@ -443,6 +452,7 @@ resource "aws_cloudwatch_metric_alarm" "nacl_changes" {
443452
metric_name = join("", aws_cloudwatch_log_metric_filter.nacl_changes.*.id)
444453
namespace = var.alarm_namespace
445454
period = "300"
455+
unit = var.unit
446456
statistic = "Sum"
447457
threshold = "1"
448458
alarm_description = "Monitoring changes to NACLs will help ensure that AWS resources and services are not unintentionally exposed."
@@ -481,6 +491,7 @@ resource "aws_cloudwatch_metric_alarm" "network_gw_changes" {
481491
metric_name = join("", aws_cloudwatch_log_metric_filter.network_gw_changes.*.id)
482492
namespace = var.alarm_namespace
483493
period = "300"
494+
unit = var.unit
484495
statistic = "Sum"
485496
threshold = "1"
486497
alarm_description = "Monitoring changes to network gateways will help ensure that all ingress/egress traffic traverses the VPC border via a controlled path."
@@ -518,6 +529,7 @@ resource "aws_cloudwatch_metric_alarm" "route_table_changes" {
518529
metric_name = join("", aws_cloudwatch_log_metric_filter.route_table_changes.*.id)
519530
namespace = var.alarm_namespace
520531
period = "300"
532+
unit = var.unit
521533
statistic = "Sum"
522534
threshold = "1"
523535
alarm_description = "Monitoring changes to route tables will help ensure that all VPC traffic flows through an expected path."
@@ -555,6 +567,7 @@ resource "aws_cloudwatch_metric_alarm" "vpc_changes" {
555567
metric_name = join("", aws_cloudwatch_log_metric_filter.vpc_changes.*.id)
556568
namespace = var.alarm_namespace
557569
period = "300"
570+
unit = var.unit
558571
statistic = "Sum"
559572
threshold = "1"
560573
alarm_description = "Monitoring changes to VPC will help ensure that all VPC traffic flows through an expected path."

modules/alarm/variables.tf

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,13 @@ variable "environment" {
1919
}
2020

2121
variable "label_order" {
22-
type = list
22+
type = list(any)
2323
default = []
2424
description = "Label order, e.g. `name`,`application`."
2525
}
2626

2727
variable "attributes" {
28-
type = list
28+
type = list(any)
2929
default = []
3030
description = "Additional attributes (e.g. `1`)."
3131
}
@@ -37,7 +37,7 @@ variable "delimiter" {
3737
}
3838

3939
variable "tags" {
40-
type = map
40+
type = map(any)
4141
default = {}
4242
description = "Additional tags (e.g. map(`BusinessUnit`,`XYZ`)."
4343
}
@@ -60,6 +60,11 @@ variable "no_mfa_console_signin" {
6060
description = "If you want to create alarm when MFA not enabled on root user."
6161
}
6262

63+
variable "unit" {
64+
type = string
65+
default = "None"
66+
}
67+
6368
variable "root_usage" {
6469
type = bool
6570
default = true

variables.tf

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ variable "environment" {
1919
}
2020

2121
variable "label_order" {
22-
type = list
22+
type = list(any)
2323
default = []
2424
description = "Label order, e.g. `name`,`application`."
2525
}
@@ -31,7 +31,7 @@ variable "managedby" {
3131
}
3232

3333
variable "attributes" {
34-
type = list
34+
type = list(any)
3535
default = []
3636
description = "Additional attributes (e.g. `1`)."
3737
}
@@ -49,7 +49,7 @@ variable "cloudtrail_s3_policy" {
4949
}
5050

5151
variable "tags" {
52-
type = map
52+
type = map(any)
5353
default = {}
5454
description = "Additional tags (e.g. map(`BusinessUnit`,`XYZ`)."
5555
}
@@ -117,6 +117,11 @@ variable "alarm_enabled" {
117117
default = true
118118
}
119119

120+
variable "unit" {
121+
type = string
122+
default = "None"
123+
}
124+
120125
variable "unauthorized_api_calls" {
121126
type = bool
122127
default = true
@@ -213,13 +218,13 @@ variable "guardduty_s3_bucket_name" {
213218
}
214219

215220
variable "ipset_iplist" {
216-
type = list
221+
type = list(any)
217222
description = "IPSet list of trusted IP addresses"
218223
default = []
219224
}
220225

221226
variable "threatintelset_iplist" {
222-
type = list
227+
type = list(any)
223228
description = "ThreatIntelSet list of known malicious IP addresses"
224229
default = []
225230
}

0 commit comments

Comments
 (0)