Skip to main content

Triage and Remediation

Remediation

Using Console

To remediate Audit Configuration Logging for GCP IAM using the GCP Console, you need to ensure that Cloud Audit Logs (especially Admin Activity and appropriate Data Access logs) are enabled for IAM and that logs are being exported/retained as needed.

1. Verify IAM Audit Logs Are Enabled

  1. Go to Google Cloud Console:
    https://console.cloud.google.com
  2. Select the project (or folder/organization) you want to remediate from the top project selector.
  3. In the left menu, go to:
    IAM & Admin → Audit Logs
  4. At the top, select the scope:
    • If you have access, switch to Organization or Folder level using the scope selector.
    • Otherwise, do it at the project level.
  5. In the “Audit logs” page:
    • In the Service list, find and select:
      • IAM Service Account Credentials API
      • Cloud Identity and Access Management (iam.googleapis.com)
        (names may vary slightly, but look for IAM-related services)
    • Or simply click All services if your policy requires global coverage.
  6. For each relevant service, ensure:
    • Admin Read: Enabled (checkbox checked)
    • Admin Write: Enabled
    • Data Read: Enable if your policy requires data access logging
    • Data Write: Enable if your policy requires data access logging
  7. Click Save at the bottom.
Note:
  • Admin Activity logs are on by default and can’t be disabled, but explicitly enabling the checkboxes ensures consistent configuration and visibility in the UI.
  • Data Access logs (Data Read/Write) may incur additional cost; enable them to match your compliance requirements.

2. Confirm Logs Are Being Written

  1. Go to Logging → Logs Explorer in the left menu.
  2. Ensure the correct project is selected at the top.
  3. In the query builder, run a basic query to view IAM audit logs, for example:
    • Click “Query builder → Resource”, select a resource type like:
      • IAM Service Account, or
      • Project
    • Then in the Log name filter, choose:
      • cloudaudit.googleapis.com/activity
      • and/or cloudaudit.googleapis.com/data
  4. Click Run query and verify that IAM-related admin and data access events are appearing.

3. (Optional) Configure Log Retention or Export

If your audit requirement includes long-term retention or external SIEM:
  1. Go to Logging → Log Router.
  2. Click Create Sink:
    • Give it a name (e.g., iam-audit-logs-sink).
    • In the Sink destination, choose:
      • Cloud Storage (for archive), or
      • BigQuery (for analytics), or
      • Pub/Sub (for SIEM forwarding).
  3. In the Build inclusion filter, restrict to IAM audit logs, for example:
  4. Complete sink creation, granting the sink’s service account the required write permissions on the destination.

4. (Optional) Enforce via Organization Policy

To prevent disabling audit logs:
  1. Go to IAM & Admin → Organization policies.
  2. Search for policies related to:
    • constraints/logging.adminActivityService
    • constraints/logging.dataAccessService
  3. Edit and set them to enforce required logging for IAM services.

This sequence ensures IAM configuration changes and access are fully logged and retained according to compliance requirements using only the GCP Console.
Below are the steps to remediate “Audit Configuration Logging” issues for GCP IAM by enabling Audit Logs using the gcloud CLI. I’ll show it at the project level; you can adapt for folders/organization.

1. Set your target project

Replace PROJECT_ID with your project ID.

2. Export current IAM policy to a file

This creates iam-policy.json that you’ll edit to add auditConfigs.

3. Edit the IAM policy to add audit logging

Open iam-policy.json in an editor and add or update the auditConfigs section.

Example: Enable all audit log types for all services

Add this top-level block (sibling to "bindings"):
Notes:
  • service: "allServices" enables audit logging for every supported Google Cloud service.
  • logTypes:
    • ADMIN_READ – read operations on configuration/resources.
    • DATA_READ – read access to user data.
    • DATA_WRITE – write access to user data.
  • If you need to exempt service accounts from specific logs, add:
Keep the rest of the file unchanged.

4. Re-apply the updated IAM policy

Confirm that the command succeeds and doesn’t report invalid JSON or fields.

5. Verify the audit configuration

You should see the allServices audit configuration with ADMIN_READ, DATA_READ, and DATA_WRITE.

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

Organization:
Folder:

These steps remediate audit configuration logging issues by ensuring IAM audit logs (Admin & Data) are enabled via the GCP CLI.
Below are step‑by‑step instructions and a Python example to remediate missing Audit Configuration Logging for GCP IAM (i.e., enable Data Access audit logs via IAM auditConfigs).

1. Decide the Scope and Services

First decide:
  • Scope: organization, folder, or project
    • Org: organizations/1234567890
    • Folder: folders/34567890
    • Project: projects/my-project-id or projects/1234567890
  • Services to log:
    • "allServices" (recommended) or specific services like "iam.googleapis.com"
  • Log types:
    • "ADMIN_READ", "DATA_READ", "DATA_WRITE"
      (Admin Activity logs are always on and free; Data Access logs can generate cost.)
Example choice (recommended baseline):

2. Enable Required APIs

Make sure the following APIs are enabled on the project you use to run the script:
  • Cloud Resource Manager API (cloudresourcemanager.googleapis.com)
  • IAM API (iam.googleapis.com) – not strictly necessary to update auditConfigs, but often used in tandem

3. Set Up Authentication

Use a service account with Owner or at least:
  • resourcemanager.organizations.setIamPolicy or
  • resourcemanager.projects.setIamPolicy / resourcemanager.folders.setIamPolicy
Authenticate locally:
Your Python code will then pick up the ADC (Application Default Credentials).

4. Python Code: Enable Audit Config Logging

This example:
  • Reads the current IAM policy at the scope.
  • Merges/updates the auditConfigs for allServices.
  • Ensures both DATA_READ and DATA_WRITE are enabled.
  • Writes the policy back.

Adjusting for Organization or Folder

Change the client calls:
  • For organization:
  • For folder:

5. Verify in Cloud Console

  1. Go to IAM & Admin → Audit Logs.
  2. Select the project / folder / organization.
  3. Confirm:
    • Service: All services (or the one you configured).
    • Log Types: Data Read and Data Write are enabled.

If you tell me your exact scope (project/org) and whether you want all services or specific ones (like just IAM), I can tailor the code snippet precisely to that.
For organization‑wide logging instead of per‑project, use:
This enables Cloud Audit Logs for all services and all log types at the project or organization level.Verification: terraform plan should show creation (or update) of the google_project_iam_audit_config or google_organization_iam_audit_config resource with service = "allServices" and the three audit_log_config blocks for ADMIN_READ, DATA_READ, and DATA_WRITE.