AWS Management Console 인증 실패 감지 알람이 없는 CloudWatch

AWS 콘솔 로그인 실패에 대한 알림을 설정하세요.

설명

AWS 콘솔 로그인 실패를 모니터링하세요. 입력 실수일 수도 있고 계정에 접근하려는 반복 시도일 수도 있습니다.

잠재적 영향

알림을 받는 사람이 없으면 반복되는 로그인 실패를 놓칠 수 있습니다.

해결 방법

CloudTrail 이벤트를 CloudWatch Logs에 보내세요. ConsoleLogin 이벤트 중 오류 메시지가 Failed authentication인 경우를 집계하세요. 알람을 해당 지표에 연결하고 임계값과 알림 대상을 지정하세요.

예시

예시의 임계값은 5분 동안 한 번 이상 실패하는 경우입니다.

변경 전

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"
}

변경 후

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"
}

참조