Skip to main content

Triage and Remediation

Remediation

Using Console

To remediate “Audit Logging not enabled” for GCP IAM using the GCP Console:
  1. Go to the GCP Console
  2. Open Audit Logs settings
    • In the left-hand menu, go to:
      IAM & Admin → Audit Logs
  3. Select the resource scope
    • At the top of the page, use the drop-down to choose the scope you want to configure:
      • Organization (preferred for centralized control), or
      • Folder, or
      • Project
  4. Filter to IAM-related services
    In the service list, locate and configure at least:
    • IAM Service
    • IAM Service Account
    • Cloud Resource Manager (often also important for IAM-like changes, e.g., project bindings)
    You can use the filter box to search for “IAM”.
  5. Enable the desired audit log types
    For each of the relevant services (e.g., IAM Service):
    • Click the service name (or checkbox, depending on UI version).
    • On the right (or in the panel that appears), enable the log types you need by checking:
      • Admin Read – controls/reads IAM policies, roles, etc.
      • Data Read – reads of data (less relevant specifically for IAM, but good to have if required by policy).
      • Data Write – changes to data/resources (e.g., policy updates, role bindings).
    • For strict security/compliance, enable all three for applicable principals:
      • You’ll see columns like All users, Admin, Service accounts, etc. Ensure these are checked according to your org’s policy (many orgs enable for All principals).
  6. Save the configuration
    • After selecting the log types, click Save at the bottom/right of the panel.
  7. Verify logs are being written
    • Go to Logging → Logs Explorer.
    • In the query builder, filter by:
      • resource.type="project" (or org/folder type as appropriate)
      • logName:"cloudaudit.googleapis.com"
    • Make a small IAM change (e.g., add/remove a test role) and confirm an AuditLog entry appears.
Once these steps are complete, IAM audit logging is enabled and the “Audit Logging Enabled” misconfiguration for GCP IAM should be remediated for that scope.
In GCP, “Audit Logging enabled” for IAM usually means Data Access audit logs are turned on (Admin Activity logs are always on). You enable these by adding auditConfigs to the IAM policy using gcloud.Below is how to do it with GCP CLI at the project level (similar for folder/org).

1. Set environment variables


2. Export current IAM policy to a file


3. Edit the IAM policy to add auditConfigs

Open iam-policy.json in an editor and add an auditConfigs block at the top level (sibling to bindings).
Example to enable all Data Access logs for all services and no exemptions:
Notes:
  • Keep the existing etag unchanged.
  • If auditConfigs already exists, merge your desired auditLogConfigs instead of overwriting unrelated entries.
  • You can also set for a specific service, e.g. "service": "iam.googleapis.com" instead of "allServices".

4. Apply the updated IAM policy

Confirm the updated policy:

5. (Optional) Do the same at folder / org level

For a folder:
For an org:
This enables IAM Data Access audit logging via CLI in GCP.
To remediate “Audit Logging not enabled” for GCP IAM using Python, you need to update the project’s IAM policy to include auditConfigs for the services you care about (e.g., allServices) and log types (ADMIN_READ, DATA_READ, DATA_WRITE).Below is a minimal, step‑by‑step example using the google-api-python-client library.

1. Prerequisites

  1. Enable these APIs on the project:
    • IAM Service: iam.googleapis.com
    • Cloud Resource Manager API: cloudresourcemanager.googleapis.com
  2. Install libraries:
  3. Authenticate with an identity that has resourcemanager.projects.setIamPolicy and resourcemanager.projects.getIamPolicy (e.g., Owner or Security Admin):

2. Decide what to log

Common secure baseline for all services:
  • ADMIN_READ
  • DATA_READ
  • DATA_WRITE
Optionally include exemptedMembers if some principals must be excluded from logging.

3. Python: Enable Audit Logging on a Project


4. Verify in Console

  1. Go to: IAM & Admin → Audit Logs → Select project.
  2. Confirm that for “All services” (or specific services), the chosen log types (Admin, Data read/write) are enabled.
  3. Optionally check Cloud Logging → Logs Explorer for cloudaudit.googleapis.com logs.
Replace YOUR_PROJECT_ID with your actual project ID.
This updates the IAM audit logging configuration in place; it does not recreate the project or other resources.
For verification, terraform plan should show an update to google_project_iam_audit_config.all_services_audit_logging adding the three audit_log_config blocks (ADMIN_READ, DATA_READ, DATA_WRITE).