Triage and Remediation
- Remediation
Remediation
Using Console
Using Console
To remediate “Audit Logging not enabled” for GCP IAM using the GCP Console:
-
Go to the GCP Console
- Open: https://console.cloud.google.com
- Make sure you’ve selected the correct Project (or Folder/Organization) at the top.
-
Open Audit Logs settings
- In the left-hand menu, go to:
IAM & Admin → Audit Logs
- In the left-hand menu, go to:
-
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
- At the top of the page, use the drop-down to choose the scope you want to configure:
-
Filter to IAM-related services
In the service list, locate and configure at least:IAM ServiceIAM Service AccountCloud Resource Manager(often also important for IAM-like changes, e.g., project bindings)
-
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).
-
Save the configuration
- After selecting the log types, click Save at the bottom/right of the panel.
-
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.
Using CLI
Using CLI
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
Example to enable all Data Access logs for all services and no exemptions:Notes:
Confirm the updated policy:
For an org:This enables IAM Data Access audit logging via CLI in GCP.
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
Openiam-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:
- Keep the existing
etagunchanged. - If
auditConfigsalready exists, merge your desiredauditLogConfigsinstead 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
5. (Optional) Do the same at folder / org level
For a folder:Using Python
Using Python
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
- Enable these APIs on the project:
- IAM Service:
iam.googleapis.com - Cloud Resource Manager API:
cloudresourcemanager.googleapis.com
- IAM Service:
- Install libraries:
- Authenticate with an identity that has
resourcemanager.projects.setIamPolicyandresourcemanager.projects.getIamPolicy(e.g., Owner or Security Admin):
2. Decide what to log
Common secure baseline for all services:ADMIN_READDATA_READDATA_WRITE
exemptedMembers if some principals must be excluded from logging.3. Python: Enable Audit Logging on a Project
4. Verify in Console
- Go to: IAM & Admin → Audit Logs → Select project.
- Confirm that for “All services” (or specific services), the chosen log types (Admin, Data read/write) are enabled.
- Optionally check Cloud Logging → Logs Explorer for
cloudaudit.googleapis.comlogs.
Using Terraform
Using Terraform
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).
