설명
AWS 루트 사용자는 꼭 필요한 작업에만 쓰고, 누군가 직접 사용하면 계정 담당자에게 알리세요.
잠재적 영향
승인되지 않은 루트 사용자 작업은 계정 전반의 리소스에 영향을 줄 수 있습니다.
해결 방법
CloudTrail 이벤트를 CloudWatch Logs에 보내세요. Root 활동을 필터링할 때 AWS 서비스가 대신 호출한 이벤트와 AwsServiceEvent를 제외하세요. 필터가 출력한 지표를 알람에 지정하고 알림 대상을 설정하세요.
예시
변경 전
hcl
resource "aws_cloudwatch_log_metric_filter" "example" {
name = "CIS-RootAccountUsage"
pattern = "{ $.userIdentity.type = \"Root\" && $.userIdentity.invokedBy NOT EXISTS && $.eventType != \"AwsServiceEvent\" }"
log_group_name = aws_cloudwatch_log_group.CIS_CloudWatch_LogsGroup.name
metric_transformation {
name = "CIS-RootAccountUsage"
namespace = "CIS_Metric_Alarm_Namespace"
value = "1"
}
}
resource "aws_cloudwatch_metric_alarm" "example" {
alarm_name = "CIS-3.3-RootAccountUsage"
comparison_operator = "GreaterThanOrEqualToThreshold"
evaluation_periods = "1"
metric_name = "XXX NOT YOUR FILTER XXX"
namespace = "CIS_Metric_Alarm_Namespace"
period = "300"
statistic = "Sum"
threshold = "1"
}
변경 후
hcl
resource "aws_cloudwatch_log_metric_filter" "example" {
name = "CIS-RootAccountUsage"
pattern = "{ $.userIdentity.type = \"Root\" && $.userIdentity.invokedBy NOT EXISTS && $.eventType != \"AwsServiceEvent\" }"
log_group_name = aws_cloudwatch_log_group.CIS_CloudWatch_LogsGroup.name
metric_transformation {
name = "CIS-RootAccountUsage"
namespace = "CIS_Metric_Alarm_Namespace"
value = "1"
}
}
resource "aws_cloudwatch_metric_alarm" "example" {
alarm_name = "CIS-3.3-RootAccountUsage"
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"
}