HomeAbout MeBook a Call

Building a Low Code Cloud IAM Auditor with Google Sheets and Vertex AI

By Vo Tu Duc
Published in Cloud Engineering
March 22, 2026
Building a Low Code Cloud IAM Auditor with Google Sheets and Vertex AI

In the rush for cloud agility, identities silently accumulate unnecessary access rights that drastically expand the blast radius of a potential breach. Discover the hidden dangers of privilege creep and how to secure your environment against over-permissioned accounts.

image 0

The Threat of Privilege Creep in Cloud Environments

In the dynamic landscape of cloud engineering, agility is often prioritized above all else. Developers spin up new environments, architects deploy complex microservices, and data scientists access massive datasets to train models. However, this rapid pace of innovation frequently gives birth to a silent, pervasive security risk: privilege creep.

Privilege creep occurs when cloud identities—whether they are human users, service accounts, or third-party applications—gradually accumulate access rights beyond what is strictly necessary for their current roles. In a Google Cloud environment, a developer might be granted roles/editor on a project to troubleshoot a specific production issue. Once the issue is resolved, that elevated access is rarely revoked. Over months and years, these dormant privileges compound, drastically expanding the “blast radius” of a potential security incident. If an attacker compromises an identity suffering from privilege creep, or if an insider threat emerges, the resulting damage to your cloud infrastructure and sensitive data can be catastrophic.

Enforcing the Principle of Least Privilege (PoLP) is a foundational tenet of cloud security, but maintaining it against the constant tide of organizational changes, project migrations, and evolving technical requirements is an ongoing battle.

Understanding Unauthorized Cloud Permissions

To effectively combat privilege creep, we must first understand the nature of unauthorized cloud permissions. In the context of Google Cloud IAM, “unauthorized” doesn’t solely mean access gained by a malicious hacker; more often, it refers to legitimate identities holding permissions they no longer need, or should never have had in the first place.

These unauthorized permissions typically manifest in a few common ways:

image 1
  • Over-reliance on Primitive Roles: The use of broad primitive roles like Owner, Editor, and Viewer is a primary culprit. An identity granted the Editor role has sweeping modification rights across almost all Google Cloud resources in a project, which is rarely necessary for a specialized task.

  • Orphaned Service Accounts: Applications and CI/CD pipelines require service accounts to interact with Google Cloud APIs. When a project is deprecated or an application is retired, the associated service accounts—and their highly privileged IAM bindings—are frequently left behind.

  • Role Transitions and Offboarding: When employees change departments or leave the company, their access needs change. Without rigorous automated lifecycle management, a user might retain access to their old team’s BigQuery datasets or Compute Engine instances long after they have moved on.

  • Wildcard Permissions: Custom IAM roles that utilize wildcards (e.g., storage.buckets.*) can inadvertently grant access to future resources that the creator never intended to expose.

Identifying these unauthorized permissions requires deep visibility into the IAM policies attached to organizations, folders, projects, and individual resources. However, visibility alone is not enough; you must also have the business context to determine if a specific IAM binding is still valid.

Challenges in Traditional IAM Auditing for Security Teams

For security teams and cloud administrators, auditing IAM policies is a notoriously painful process. Traditional approaches to User Access Reviews (UARs) and permission auditing are fraught with systemic challenges that make them slow, inaccurate, and universally disliked.

1. The Scale and Complexity of Cloud IAM

Modern cloud environments are incredibly complex. A mid-sized organization might have hundreds of Google Cloud projects, thousands of service accounts, and tens of thousands of IAM bindings. Extracting this data using tools like Cloud Asset Inventory or gcloud CLI scripts results in massive, unreadable JSON or CSV files. Parsing this data to find meaningful anomalies is like finding a needle in a digital haystack.

2. The “Context Disconnect”

Security teams have visibility into what permissions exist, but they rarely have the business context to know why they exist. If a security engineer sees that an external contractor has roles/cloudsql.admin on a specific database, they cannot unilaterally revoke it without risking an operational outage. They must track down the resource owner to verify the access, creating a massive communication bottleneck.

3. Manual, Spreadsheet-Driven Workflows

Historically, bridging this context gap meant exporting IAM data into static spreadsheets, breaking them apart, and emailing them to various department heads for review. Managers are forced to manually sift through rows of cryptic IAM roles and service account IDs, often rubber-stamping approvals just to get back to their actual jobs. By the time the spreadsheet makes it back to the security team for remediation, the data is already weeks out of date.

4. Alert Fatigue and Tooling Silos

While Cloud Security Posture Management (CSPM) tools can flag overly permissive roles, they often generate a high volume of alerts without providing an easy remediation path. Security teams suffer from alert fatigue, and the lack of an integrated, automated workflow means that identified risks often sit in a backlog rather than being actively addressed.

To secure modern cloud infrastructure, security teams need a paradigm shift. They need a solution that bridges the gap between complex IAM data and human business context, automating the tedious aspects of auditing while empowering resource owners to make informed access decisions.

Architecting a Custom Low Code Security Auditor

Building a robust security auditing tool doesn’t always require deploying complex microservices, provisioning Kubernetes clusters, or writing thousands of lines of Go. By strategically bridging Automatically create new folders in Google Drive, generate templates in new folders, fill out text automatically in new files, and save info in Google Sheets and Google Cloud Platform (GCP), we can engineer a serverless, low-code architecture that is both highly effective and incredibly easy to maintain.

This architecture relies on three core pillars: AI Powered Cover Letter Automation Engine acting as the serverless orchestration layer, Google Sheets serving as the accessible data store and UI, and Building Self Correcting Agentic Workflows with Vertex AI providing the analytical brain for threat detection. Together, these components create an automated pipeline that continuously monitors, records, and evaluates your cloud identity landscape without the overhead of traditional infrastructure.

Connecting GCP Cloud Identity API with Apps Script

The first step in our pipeline is gaining visibility into who has access to what. Genesis Engine AI Powered Content to Video Production Pipeline (GAS) is the perfect low-code glue for this task. Operating as a serverless execution environment natively integrated with Google’s ecosystem, GAS can seamlessly authenticate and interact with GCP APIs.

To extract identity and access data, we need to connect Apps Script to the GCP Cloud Identity API and the Admin SDK. By linking your Apps Script project to a standard GCP project, you can enable the necessary OAuth 2.0 scopes (such as https://www.googleapis.com/auth/cloud-identity.groups.readonly).

Instead of dealing with complex service account key rotation, Apps Script handles authentication natively. You can use ScriptApp.getOAuthToken() to pass a Bearer token directly into a UrlFetchApp request targeting the Cloud Identity REST endpoints.

Here is a conceptual look at how you might fetch group memberships:


function fetchCloudIdentityData() {

const endpoint = 'https://cloudidentity.googleapis.com/v1/groups/{group_id}/memberships';

const options = {

method: 'get',

headers: {

Authorization: 'Bearer ' + ScriptApp.getOAuthToken(),

Accept: 'application/json'

},

muteHttpExceptions: true

};

const response = UrlFetchApp.fetch(endpoint, options);

const data = JSON.parse(response.getContentText());

// Process and return the membership data

return data.memberships;

}

Through this connection, your script can run on a time-driven trigger (e.g., every hour), continuously polling the API for new users, group modifications, or changes in IAM role bindings.

Using Google Sheets as a Forensic Log Data Store

Once the IAM data is extracted, it needs to be stored, tracked, and made readable for security administrators. In a low-code paradigm, Google Sheets is far more than just a spreadsheet—it acts as a lightweight, serverless database and a ready-made graphical user interface.

By utilizing the SpreadsheetApp service, Apps Script can parse the JSON payloads from the Cloud Identity API and append them as structured rows in a designated sheet. You can design your schema with columns such as Timestamp, Actor, Action (e.g., ADD_MEMBER), Target Resource, and Granted Role.

Using Google Sheets as your forensic ledger offers several distinct advantages for cloud engineering teams:

  • Built-in Revision History: Google Sheets natively tracks cell-level changes. If an auditor needs to prove the state of the logs at a specific point in time, the version history provides an immutable, out-of-the-box audit trail.

  • Native Filtering and Visualization: Security teams can instantly use pivot tables, filter views, and conditional formatting to hunt for specific events without needing to write SQL queries.

  • Access Control: You can leverage Workspace’s native sharing settings to restrict access to the audit log, ensuring only authorized security personnel can view the forensic data.


function logToSheet(auditRecord) {

const sheet = SpreadsheetApp.getActiveSpreadsheet().getSheetByName('IAM_Logs');

// Append the structured data: [Date, Actor, Action, Resource, Role]

sheet.appendRow([new Date(), auditRecord.actor, auditRecord.action, auditRecord.resource, auditRecord.role]);

}

Integrating Vertex AI for Intelligent Threat Detection

Collecting logs is only half the battle; the real value lies in identifying anomalies and potential security risks. Traditional auditors rely on static, rule-based alerts (e.g., “Alert if someone is granted Organization Admin”). However, these rules often generate alert fatigue and miss nuanced, context-dependent threats. This is where Vertex AI elevates our low-code auditor into an intelligent security tool.

By integrating a Large Language Model (LLM) like Gemini 1.5 Pro via the Vertex AI API, we can analyze IAM changes contextually. We can pass the newly appended log rows to Vertex AI and prompt the model to evaluate the risk based on the principle of least privilege, historical context, and naming conventions.

To achieve this, Apps Script makes a POST request to the Vertex AI endpoint. You must ensure your script has the https://www.googleapis.com/auth/cloud-platform scope. You can craft a prompt that feeds the model the specific IAM change and asks for a JSON response containing a Risk_Score (1-10) and a Reasoning string.


function analyzeRiskWithVertexAI(auditRecord) {

const projectId = 'YOUR_PROJECT_ID';

const location = 'us-central1';

const model = 'gemini-1.5-pro-preview-0409';

const endpoint = `https://${location}-aiplatform.googleapis.com/v1/projects/${projectId}/locations/${location}/publishers/google/models/${model}:generateContent`;

const prompt = `Analyze the following GCP IAM change for security risks.

Actor: ${auditRecord.actor}

Action: ${auditRecord.action}

Role: ${auditRecord.role}.

Respond in strict JSON format with "Risk_Score" (1-10) and "Reasoning".`;

const payload = {

contents: [{ role: "user", parts: [{ text: prompt }] }]

};

const options = {

method: 'post',

contentType: 'application/json',

headers: { Authorization: 'Bearer ' + ScriptApp.getOAuthToken() },

payload: JSON.stringify(payload)

};

const response = UrlFetchApp.fetch(endpoint, options);

const result = JSON.parse(response.getContentText());

return extractJsonFromVertex(result);

}

Once Vertex AI returns its assessment, Apps Script writes the Risk_Score and Reasoning directly into the adjacent columns in Google Sheets. You can then apply conditional formatting to highlight rows with a risk score of 8 or higher in red. Suddenly, your low-code spreadsheet transforms into an AI-driven Security Information and Event Management (SIEM) dashboard, capable of flagging suspicious behavior—like a marketing intern being granted roles/editor on a production billing project—without writing a single line of complex machine learning code.

Building the IAM Scanning Workflow

With our foundational architecture in place, it is time to build the core engine of our low-code auditor. This workflow is responsible for querying your Google Cloud environment, transforming raw security data into a human-readable format, and leveraging artificial intelligence to flag potential security risks. By chaining together the Google Cloud SDK, AC2F Streamline Your Google Drive Workflow APIs, and Vertex AI, we create an automated, end-to-end security pipeline.

Extracting IAM Policies Using the GCP SDK

The first step in our workflow is to retrieve the current state of access controls across your Google Cloud projects. Google Cloud’s Identity and Access Management (IAM) policies are essentially collections of “bindings” that define who (members) has what access (roles) to which resources.

To extract this programmatically, we will use the Google Cloud Resource Manager SDK. This allows us to fetch the IAM policy for a specific project and parse out the active bindings.

Here is a JSON-to-Video Automated Rendering Engine snippet demonstrating how to extract these policies:


from google.cloud import resourcemanager_v3

def get_project_iam_policy(project_id: str):

"""Fetches the IAM policy for a given GCP project."""

client = resourcemanager_v3.ProjectsClient()

request = resourcemanager_v3.GetIamPolicyRequest(

resource=f"projects/{project_id}"

)

policy = client.get_iam_policy(request=request)

extracted_bindings = []

for binding in policy.bindings:

role = binding.role

for member in binding.members:

extracted_bindings.append({

"project_id": project_id,

"role": role,

"member": member,

"condition": binding.condition.title if binding.condition else "None"

})

return extracted_bindings

In this script, we initialize the ProjectsClient and request the IAM policy. We then iterate through the bindings array, flattening the nested structure so that each member-role relationship becomes a discrete record. Capturing the condition field is also critical here, as conditional IAM bindings are a key component of a mature least-privilege architecture.

Structuring and Pushing Audit Logs to SheetApp

Raw JSON output from the GCP SDK is great for machines, but our goal is to build a low-code, highly visible dashboard using Google Sheets. To do this, we need to structure our extracted bindings into a tabular format and push them into our spreadsheet environment.

By formatting the data as a simple 2D array (rows and columns), we can easily push it to Google Sheets using the Google Sheets API. Once the data lands in the spreadsheet, it becomes accessible to Architecting Multi Tenant AI Workflows in Google Apps Script (SpreadsheetApp), allowing for further low-code manipulation, filtering, and reporting.


from googleapiclient.discovery import build

from google.oauth2 import service_account

def push_to_sheets(spreadsheet_id, range_name, data):

"""Pushes structured IAM data to Google Sheets."""

# Assuming credentials are set up in your environment

service = build('sheets', 'v4')

# Convert list of dicts to a 2D array for Sheets

sheet_data = [["Project ID", "Member", "Role", "Condition"]]

for row in data:

sheet_data.append([row['project_id'], row['member'], row['role'], row['condition']])

body = {

'values': sheet_data

}

# Execute the batch update

result = service.spreadsheets().values().update(

spreadsheetId=spreadsheet_id,

range=range_name,

valueInputOption="USER_ENTERED",

body=body

).execute()

print(f"{result.get('updatedCells')} cells updated.")

This function takes our flattened IAM data, adds a header row, and performs a bulk update to the target Google Sheet. Using USER_ENTERED ensures that the data is formatted correctly within the Sheet, making it immediately readable for your security team and ready for the next phase: AI analysis.

Prompting Gemini to Highlight Over Privileged Users

With our IAM data neatly organized in Google Sheets, we can now introduce Vertex AI to act as our automated security analyst. We will use Gemini, Google’s highly capable multimodal LLM, to evaluate the IAM bindings and identify users or service accounts that violate the principle of least privilege.

The secret to getting reliable, structured insights from Gemini lies in the prompt design. We need to provide Gemini with a clear persona, specific security rules (e.g., flagging basic roles like roles/owner or roles/editor), and the structured data we just extracted.

Here is how we can implement the Vertex AI integration:


import vertexai

from vertexai.generative_models import GenerativeModel, GenerationConfig

def analyze_iam_with_gemini(iam_records):

"""Uses Vertex AI Gemini to analyze IAM records for security risks."""

vertexai.init(project="your-security-project-id", location="us-central1")

model = GenerativeModel("gemini-1.5-pro-preview-0409")

prompt = f"""

You are an expert Cloud Security Architect auditing a Google Cloud environment.

Review the following IAM bindings and identify any over-privileged users.

Specifically, flag:

1. Any user or service account with basic legacy roles (e.g., roles/owner, roles/editor).

2. Service accounts that appear to have human-like access or overly broad admin permissions.

3. High-privilege roles granted without IAM conditions.

Return your analysis as a JSON array of objects with the keys: 'member', 'role', 'risk_level' (High/Medium/Low), and 'reason'.

IAM Data:

{iam_records}

"""

# Enforce JSON output for easy parsing back into our Sheet

generation_config = GenerationConfig(

response_mime_type="application/json",

temperature=0.2 # Low temperature for more deterministic, analytical output

)

response = model.generate_content(prompt, generation_config=generation_config)

return response.text

By setting the response_mime_type to application/json and keeping the temperature low, we ensure Gemini returns a predictable, structured response. This JSON output can then be parsed and pushed back into an “Audit Findings” tab in our Google Sheet. This transforms a static list of permissions into an intelligent, actionable security dashboard where high-risk, over-privileged users are automatically highlighted for immediate remediation.

Forensic Analysis and Security Remediation

With Vertex AI having processed your raw IAM bindings and injected its intelligence back into your Google Sheet, the heavy lifting of data correlation is complete. However, identifying a vulnerability is only half the battle; the true value of this low-code architecture lies in how quickly you can investigate these insights and remediate the underlying risks. By bridging the gap between advanced machine learning and accessible spreadsheet interfaces, we can streamline the forensic process and enforce the Principle of Least Privilege (PoLP) with unprecedented efficiency.

Reviewing AI Flagged Anomalies in Your Spreadsheet

Your Google Sheet has now transformed from a static list of IAM policies into an interactive Security Operations (SecOps) dashboard. Because Vertex AI evaluates the context of permissions rather than just matching static rules, the data you are looking at is highly curated.

To effectively triage these anomalies, you should leverage native Automated Client Onboarding with Google Forms and Google Drive. features to organize the AI’s output:

  • Conditional Formatting for Triage: Set up conditional formatting rules based on the Risk Score column generated by Vertex AI. For instance, configure the sheet to highlight rows in deep red for scores 8-10 (Critical), orange for 5-7 (Medium), and green for anything lower. This provides an immediate visual heat map of your cloud security posture.

  • **Analyzing the AI Justification: The most powerful column in your sheet is the AI Justification or Reasoning output. Instead of simply flagging a user, Vertex AI explains why the binding is dangerous. You might see an explanation like: “Service account ‘dev-ops-ci@…’ holds roles/owner at the project level, but its naming convention implies it should only have CI/CD pipeline permissions. High risk of privilege escalation.” This natural language context drastically reduces the time your security team spends investigating false positives.

  • Filter Views for Targeted Forensics: Create saved Filter Views for different stakeholders. You can filter by Resource Type (e.g., Cloud Storage buckets vs. BigQuery datasets) or isolate specific domains (e.g., flagging any principal ending in @gmail.com that has been granted access to production environments).

When a legitimate threat is verified in the sheet, your remediation step is straightforward: pivot directly to the Google Cloud Console (or use your Infrastructure as Code repositories, like Terraform) to revoke or downgrade the overly permissive roles, using the AI’s justification as your audit trail for the change.

Automating Alerts for Continuous Security Posture

A point-in-time audit is a great start, but cloud environments are highly dynamic. Developers spin up new resources, assign temporary permissions, and often forget to revoke them. To maintain a Continuous Security Posture Management (CSPM) lifecycle, we need to transition this low-code tool from a manual audit script into an automated alerting engine.

Because our architecture is built on Automated Discount Code Management System, we can use Google Apps Script to automate the entire pipeline and push critical alerts directly to your team’s communication channels.

Here is how you can architect the automation:

  1. Time-Driven Triggers: Utilize Apps Script’s native time-driven triggers (the Automated Email Journey with Google Sheets and Google Analytics equivalent of a cron job). You can configure the script to fetch the latest IAM policies, pass them to the Vertex AI endpoint, and update the Google Sheet automatically every night at 2:00 AM.

  2. Threshold-Based Alerting: Add a lightweight evaluation function within your Apps Script that scans the newly updated rows. If Vertex AI returns a Risk Score that exceeds your defined threshold (e.g., >= 8), the script isolates those specific records.

  3. Webhook Integration: Using the UrlFetchApp class in Apps Script, you can easily send a POST request containing the high-risk anomalies to a Google Chat Webhook, a Slack channel, or a ticketing system like Jira.

A sample alert pushed to your SecOps Google Chat space might look like this:

🚨 High-Risk IAM Anomaly Detected

Principal: [email protected]

Role: roles/iam.securityAdmin

Vertex AI Score: 9/10

Context: External domain account granted ability to modify IAM policies. Immediate review required.

[Link to Google Sheet Audit Log]

By automating this workflow, you ensure that your security team is proactively notified of risky IAM drift the moment it happens, effectively turning a simple Google Sheet and a Vertex AI prompt into a continuous, low-code cloud security auditor.

Scale Your Cloud Security Architecture

While building a low-code IAM auditor using Google Sheets and Vertex AI is an excellent starting point and highly effective for small-to-medium environments, cloud security is rarely static. As your organization’s footprint expands, the complexity of your identity perimeter multiplies. To truly secure a sprawling Google Cloud organization, your auditing mechanisms must evolve from scheduled spreadsheet checks into a resilient, automated, and event-driven security posture management system. Scaling this architecture requires bridging the gap between accessible low-code tools and robust cloud engineering practices.

Adapting the Auditor for Enterprise Workloads

When you are managing hundreds of Google Cloud projects, thousands of service accounts, and intricate organizational nodes, the inherent limits of a spreadsheet-based approach become apparent. Enterprise workloads demand high throughput, real-time analysis, and seamless integration with existing SecOps pipelines. Here is how you can elevate this low-code foundation into an enterprise-grade IAM auditing powerhouse:

  • Transitioning from Sheets to BigQuery: Google Sheets is fantastic for immediate visibility and stakeholder reporting, but BigQuery is the undisputed champion of scale. By configuring Cloud Asset Inventory (CAI) to export IAM policies directly into BigQuery, you can leverage powerful SQL queries to pre-filter baseline permissions. This allows you to isolate true anomalies before feeding them to Vertex AI, drastically reducing API payload sizes, token costs, and processing time.

  • Real-Time, Event-Driven Auditing: Shift from batch processing to an event-driven architecture. By utilizing Eventarc, you can capture IAM policy changes (such as SetIamPolicy API calls) in real-time. Route these audit logs to Cloud Run or Cloud Functions, which can instantly invoke Vertex AI to evaluate the new IAM bindings against your security baseline the moment a change occurs.

  • Advanced Vertex AI Capabilities: Move beyond basic Prompt Engineering for Reliable Autonomous Workspace Agents by leveraging Gemini’s advanced reasoning and massive context windows. You can implement Retrieval-Augmented Generation (RAG) by connecting Vertex AI to a datastore containing your internal security whitepapers, compliance frameworks (like SOC2, HIPAA, or ISO 27001), and historical audit logs. This ensures the AI provides highly contextual, compliance-aware remediation steps tailored specifically to your corporate governance.

  • Integrating with Security Command Center (SCC): A siloed auditing tool creates friction for security teams. Instead of keeping results isolated, use the SCC API to push Vertex AI-generated insights directly into Google Cloud Security Command Center as custom findings. This centralizes your security alerts, allowing your Security Operations Center (SOC) to triage AI-flagged IAM risks alongside native threat detection signals.

Book a Solution Discovery Call with Vo Tu Duc

Navigating the intersection of Cloud Identity and Access Management, generative AI, and enterprise architecture requires a strategic, battle-tested approach. Whether you want to implement the low-code auditor we’ve discussed, scale it for a massive multi-project environment, or completely revamp your Google Cloud and Automated Google Slides Generation with Text Replacement security posture, expert guidance can significantly accelerate your engineering velocity.

If you are ready to transform how your organization handles cloud security, automation, and AI integration, let’s connect. Book a Solution Discovery Call with Vo Tu Duc to discuss your specific cloud engineering challenges. Together, we can design a robust, AI-driven architecture that not only meets your strictest compliance requirements but empowers your teams to build securely and efficiently at scale.


Tags

Cloud SecurityIAMLow CodeGoogle CloudVertex AIGoogle Sheets

Share


Previous Article
Building an AI Observability Pipeline in BigQuery for Enterprise Audits
Vo Tu Duc

Vo Tu Duc

A Google Developer Expert, Google Cloud Innovator

Stop Doing Manual Work. Scale with AI.

Hi, I'm Vo Tu Duc (Danny), a recognised Google Developer Expert (GDE). I architect custom AI agents and Google Workspace solutions that help businesses eliminate chaos and save thousands of hours.

Want to turn these blog concepts into production-ready reality for your team?
Book a Discovery Call

Table Of Contents

Portfolios

AI Agentic Workflows
Change Management
AppSheet Solutions
Strategy Playbooks
Cloud Engineering
Product Showcase
Uncategorized
Workspace Automation

Related Posts

Architecting a Personalized Offer Agent Using Vertex AI
March 29, 2026
© 2026, All Rights Reserved.
Powered By

Quick Links

Book a CallAbout MeVolunteer Legacy

Social Media