Description
Monitor failed AWS console sign-ins. A failure may be a typing mistake or part of repeated attempts to access an account.
Potential impact
Repeated failures can go uninvestigated if no one receives an alert.
Remediation
Send CloudTrail events to CloudWatch Logs. Match ConsoleLogin events with the error message Failed authentication. Connect the alarm to that metric, choose a threshold, and set the notification recipient.
Examples
The example threshold is one or more failures in five minutes.
Before
hcl
resource "aws_cloudwatch_log_metric_filter" "example" {
name = "CIS-ConsoleAuthenticationFailure"
pattern = "{ ($.eventName = ConsoleLogin) && ($.errorMessage = \"Failed authentication\") }"
log_group_name = aws_cloudwatch_log_group.CIS_CloudWatch_LogsGroup.name
metric_transformation {
name = "CIS-ConsoleAuthenticationFailure"
namespace = "CIS_Metric_Alarm_Namespace"
value = "1"
}
}
resource "aws_cloudwatch_metric_alarm" "example" {
alarm_name = "CIS-3.6-ConsoleAuthenticationFailure"
comparison_operator = "GreaterThanOrEqualToThreshold"
evaluation_periods = "1"
metric_name = "XXX NOT YOUR FILTER"
namespace = "CIS_Metric_Alarm_Namespace"
period = "300"
statistic = "Sum"
threshold = "1"
}
After
hcl
resource "aws_cloudwatch_log_metric_filter" "example" {
name = "CIS-ConsoleAuthenticationFailure"
pattern = "{ (($.eventName = ConsoleLogin) && ($.errorMessage = \"Failed authentication\")) }"
log_group_name = aws_cloudwatch_log_group.CIS_CloudWatch_LogsGroup.name
metric_transformation {
name = "CIS-ConsoleAuthenticationFailure"
namespace = "CIS_Metric_Alarm_Namespace"
value = "1"
}
}
resource "aws_cloudwatch_metric_alarm" "example" {
alarm_name = "CIS-3.6-ConsoleAuthenticationFailure"
comparison_operator = "GreaterThanOrEqualToThreshold"
evaluation_periods = "1"
metric_name = aws_cloudwatch_log_metric_filter.example.id
namespace = "CIS_Metric_Alarm_Namespace"
period = "300"
statistic = "Sum"
threshold = "1"
}