Skip to main content
Five Steps for Cloud Compliance Readiness·A practical playbook for security teamsDownload
CIS Google Cloud Platform Foundation v5.0.0 · 2.7

Custom IAM role changes should raise an alert through a log-based metric

  • Level 1
  • Logging and Monitoring

This check looks for a log-based metric that counts custom IAM role create, update and delete events, with an alerting policy attached to it. The safe setting is to have both, so a change to a custom role is noticed quickly.

Why it matters

A custom IAM role is a list of permissions you define yourself. Changing one can quietly widen what every holder of that role can do, across every place the role is granted. Google Cloud writes such changes to its audit logs, but nobody reads those logs unless something prompts them to.

Google describes log-based metrics as Cloud Monitoring metrics derived from the content of log entries; a counter metric tallies how many entries match a filter, and alerting policies can monitor the result. Pairing a counter on custom-role changes with an alert turns a silent edit into a notification. Source: Log-based metrics overview (Google Cloud documentation). Note that a metric only counts logs received after it was created.

How to check it yourself

Portal: in Logging > Log-based metrics look for a user-defined counter whose filter mentions custom role changes. Then open Monitoring > Alerting and confirm an alerting policy uses that metric.

gcloud (read-only):

gcloud logging metrics list --project <project-id> --format="table(name,filter)"

Look for a filter covering the IAM admin role methods, for example google.iam.admin.v1.CreateRole, UpdateRole and DeleteRole. Then check the alerting side in the portal, since a metric nobody is alerted on does not meet the safe setting.

How to fix it

Portal: in Logging > Log-based metrics choose Create metric, type Counter, paste a filter for the role methods and save. Then create an alerting policy on logging.googleapis.com/user/<metric-name> with a notification channel your team reads.

gcloud, which changes the project, so run it yourself (ConfigCobra only reports and suggests, it never changes your environment):

gcloud logging metrics create custom-role-changes \
  --project <project-id> \
  --description="Counts custom IAM role create, update and delete events" \
  --log-filter='resource.type="iam_role" AND (protoPayload.methodName="google.iam.admin.v1.CreateRole" OR protoPayload.methodName="google.iam.admin.v1.UpdateRole" OR protoPayload.methodName="google.iam.admin.v1.DeleteRole")'

Create the alerting policy next, and set how it treats missing data, because a counter that sees no events produces gaps, which Google recommends handling explicitly.

What changes when you fix it

Nothing changes for running workloads or for people who use the roles. The only visible effect is a notification when someone edits a custom role.

  • Security and platform admins receive alerts and need a routine for reviewing them.
  • Teams that edit custom roles often may find the alert noisy at first; agree with them on which changes are expected.
  • Monitoring owners must pick the notification channel and keep it current.

Metrics and policies live in a project, so decide which project holds them and whether a metric is needed in each project or at a broader scope. Test it by making a harmless edit to a role in a test project and confirming the alert fires.

Included in

BenchmarkCIS IDProfile
CIS Google Cloud Platform Foundation v5.0.02.7Level 1

Check this on your Google Cloud

ConfigCobra runs this check with every other control of the CIS Google Cloud Platform Foundation Benchmark, read-only.

Get in touch

Let's talk.

Whether you're evaluating ConfigCobra, running an audit, or managing a client fleet — we respond within one business day.

Free trial