Triage and Remediation
- Remediation
Remediation
Using Console
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.
This sequence ensures IAM configuration changes and access are fully logged and retained according to compliance requirements using only the GCP Console.
1. Verify IAM Audit Logs Are Enabled
-
Go to Google Cloud Console:
https://console.cloud.google.com - Select the project (or folder/organization) you want to remediate from the top project selector.
-
In the left menu, go to:
IAM & Admin → Audit Logs -
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.
-
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.
- In the Service list, find and select:
-
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
- 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
- Go to Logging → Logs Explorer in the left menu.
- Ensure the correct project is selected at the top.
-
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, orProject
- Then in the Log name filter, choose:
cloudaudit.googleapis.com/activity- and/or
cloudaudit.googleapis.com/data
- Click “Query builder → Resource”, select a resource type like:
- 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:- Go to Logging → Log Router.
-
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).
- Give it a name (e.g.,
-
In the Build inclusion filter, restrict to IAM audit logs, for example:
- 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:- Go to IAM & Admin → Organization policies.
-
Search for policies related to:
constraints/logging.adminActivityServiceconstraints/logging.dataAccessService
- 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.
Using CLI
Using CLI
Below are the steps to remediate “Audit Configuration Logging” issues for GCP IAM by enabling Audit Logs using the
Replace
This creates
Notes:
Confirm that the command succeeds and doesn’t report invalid JSON or fields.
You should see the
Folder:
These steps remediate audit configuration logging issues by ensuring IAM audit logs (Admin & Data) are enabled via the GCP CLI.
gcloud CLI. I’ll show it at the project level; you can adapt for folders/organization.1. Set your target project
PROJECT_ID with your project ID.2. Export current IAM policy to a file
iam-policy.json that you’ll edit to add auditConfigs.3. Edit the IAM policy to add audit logging
Openiam-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"):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:
4. Re-apply the updated IAM policy
5. Verify the audit configuration
allServices audit configuration with ADMIN_READ, DATA_READ, and DATA_WRITE.6. (Optional) Do the same at org/folder level
Organization:These steps remediate audit configuration logging issues by ensuring IAM audit logs (Admin & Data) are enabled via the GCP CLI.
Using Python
Using Python
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
Your Python code will then pick up the ADC (Application Default Credentials).
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.
auditConfigs).1. Decide the Scope and Services
First decide:- Scope: organization, folder, or project
- Org:
organizations/1234567890 - Folder:
folders/34567890 - Project:
projects/my-project-idorprojects/1234567890
- Org:
- 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.)
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.setIamPolicyorresourcemanager.projects.setIamPolicy/resourcemanager.folders.setIamPolicy
4. Python Code: Enable Audit Config Logging
This example:- Reads the current IAM policy at the scope.
- Merges/updates the
auditConfigsforallServices. - Ensures both
DATA_READandDATA_WRITEare enabled. - Writes the policy back.
Adjusting for Organization or Folder
Change the client calls:- For organization:
- For folder:
5. Verify in Cloud Console
- Go to IAM & Admin → Audit Logs.
- Select the project / folder / organization.
- Confirm:
- Service:
All services(or the one you configured). - Log Types: Data Read and Data Write are enabled.
- Service:
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.
Using Terraform
Using Terraform
name.Verification: terraform plan should show + create for google_logging_metric.audit_config_change and google_monitoring_alert_policy.audit_config_change_alert with no unexpected changes to other resources.
