AWS Organizations 변경 감지 알람 미설정

AWS Organizations 변경을 감지하는 CloudWatch 로그 필터와 알람이 없으면 조직 단위 권한 변경을 늦게 발견할 수 있습니다.

설명

계정 이동이나 정책 연결처럼 담당 팀이 알아야 하는 AWS Organizations 변경을 CloudTrail 이벤트에서 골라 CloudWatch 경보로 연결하세요.

잠재적 영향

이런 변경을 놓치면 잘못된 계정 배치나 권한을 뒤늦게 발견할 수 있습니다.

해결 방법

CloudTrail이 해당 이벤트를 로그 그룹으로 전달할 수 있게 하세요. 필터가 생성하는 메트릭의 이름과 네임스페이스를 경보에 지정하고 임계값과 평가 기간을 정하세요. SNS 주제에 수신자를 구독시킨 뒤 조건에 맞는 이벤트가 메트릭에 반영되고 경보 상태로 바뀔 때 알림이 도착하는지 확인하세요. 로그 전달과 평가에는 시간이 걸립니다.

예시

참조된 로그 그룹과 SNS 주제를 별도로 구성하세요. 첫 필터는 EC2 이벤트를 셉니다. 두 번째는 Organizations 작업 다섯 가지를 집계하므로 필요한 다른 작업도 필터에 추가하세요.

변경 전

hcl
resource "aws_cloudwatch_log_metric_filter" "organizations_changes" {
  name           = "organizations-changes"
  log_group_name = aws_cloudwatch_log_group.cloudtrail.name
  pattern        = "{ ($.eventSource = \"ec2.amazonaws.com\") }"

  metric_transformation {
    name      = "organizations-changes"
    namespace = "Security"
    value     = "1"
  }
}

변경 후

hcl
resource "aws_cloudwatch_log_metric_filter" "organizations_changes" {
  name           = "organizations-changes"
  log_group_name = aws_cloudwatch_log_group.cloudtrail.name
  pattern        = "{ ($.eventSource = \"organizations.amazonaws.com\") && (($.eventName = AcceptHandshake) || ($.eventName = AttachPolicy) || ($.eventName = CreateAccount) || ($.eventName = MoveAccount) || ($.eventName = RemoveAccountFromOrganization)) }"

  metric_transformation {
    name      = "organizations-changes"
    namespace = "Security"
    value     = "1"
  }
}

resource "aws_cloudwatch_metric_alarm" "organizations_changes" {
  alarm_name          = "organizations-changes"
  comparison_operator = "GreaterThanOrEqualToThreshold"
  evaluation_periods  = 1
  metric_name         = "organizations-changes"
  namespace           = "Security"
  period              = 300
  statistic           = "Sum"
  threshold           = 1
  alarm_actions       = [aws_sns_topic.security_alerts.arn]
}

예시에서는 5분간 합계가 1 이상이면 경보 상태로 전환할 때 SNS에 알립니다.

참조