IAM policy changes should be monitored
Description
Real-time monitoring of API calls can be achieved by directing CloudTrail logs to CloudWatch logs and establishing corresponding metric filters and alarms. It is recommended to set up a metric filter and alarm for changes made to Identity and Access Management (IAM) policies to ensure authentication and authorization controls remain intact.
For instructions on setting up CloudWatch metric filters and alarms for IAM policy changes, refer to the AWS CloudWatch Alarms for CloudTrail User Guide.
aws logs put-metric-filter --log-group-name <cloudtrail_log_group_name> \
--filter-name <iam_changes_metric> --metric-transformations \
metricName=<iam_changes_metric>,metricNamespace='CISBenchmark',metricValue=1 \
--filter-pattern '{($.eventName=DeleteGroupPolicy)||($.eventName=DeleteRolePolicy)||($.eventName=DeleteUserPolicy)|| \
($.eventName=PutGroupPolicy)||($.eventName=PutRolePolicy)||($.eventName=PutUserPolicy)||($.eventName=CreatePolicy)|| \
($.eventName=DeletePolicy)||($.eventName=CreatePolicyVersion)||($.eventName=DeletePolicyVersion)||($.eventName=AttachRolePolicy)|| \
($.eventName=DetachRolePolicy)||($.eventName=AttachUserPolicy)||($.eventName=DetachUserPolicy)||($.eventName=AttachGroupPolicy)|| \
($.eventName=DetachGroupPolicy)}'
You can choose your own metricName
and metricNamespace
strings. Use the same metricNamespace
for all Foundations Benchmark metrics to group them together.