Iam Helper For Policy Simulator
GoogleOfficialPublished by Google
- Skill
- Workflow
- Security
- Apache-2.0
- Low risk
- Has scripts
AutoGineer summary
Written by AutoGineer from the skill’s own files, not by the author
This skill provides a structured, safety-first workflow for modifying Google Cloud IAM v1 Allow policies. By leveraging the Policy Simulator, it replays the last 90 days of access logs against proposed policy changes to identify potential access revocations before they occur. The workflow enforces strict validation gates, including a mandatory simulation step and an analysis phase, ensuring that only safe policy changes are applied to Projects, Folders, or Organizations.
What it does
- Retrieves current IAM v1 policies for Projects, Folders, or Organizations.
- Compares proposed policy changes against existing ones to prevent redundant operations.
- Simulates proposed policy changes using historical access logs via the Policy Simulator.
- Analyzes simulation results to detect potential access revocations for active workloads.
- Applies validated policy changes only after confirming no negative impact.
- Cleans up temporary files to maintain environment hygiene.
When to use it
- When you need to modify IAM v1 Allow policies on Google Cloud.
- When you want to verify that a policy change will not break existing production workloads.
- When you are working within the scope of Projects, Folders, or Organizations.
- When you need a repeatable, audited process for IAM policy updates.
Advantages
- Prevents accidental service outages caused by overly restrictive IAM changes.
- Provides data-driven validation using actual historical access patterns.
- Enforces a standardized safety workflow for all IAM modifications.
- Reduces manual error by automating the retrieval, simulation, and application steps.
Usage examples
- “I need to add the Storage Object Viewer role to a service account in my project.”
- The agent will retrieve the current policy, prepare the proposed change, run a simulation to ensure no existing access is revoked, and ask for your confirmation before applying the update.
- “Can you remove the Editor role from this user in my folder?”
- The agent will simulate the removal to check if the user or any associated workloads rely on that role, reporting any potential access revocations before proceeding.
Install
Download the skill as a ZIP:
https://mp-staging.autogineer.com/agent-skills/google/iam-helper-for-policy-simulator/downloadUnzip it into the cross-client skills folder of your project:
mkdir -p .agents/skills && unzip iam-helper-for-policy-simulator.zip -d .agents/skills
Documentation by Google
IAM Policy Simulator (v1 Allow)
You are an advanced security assistant helping users safely modify IAM policies. You must NEVER apply a modifying policy change without first running a Policy Simulation to ensure existing workloads are not disrupted. You must only use standard public gcloud commands.
Usage Attribution
MUST READ: Before executing any gcloud, REST API, or MCP command, you
MUST read and follow the instructions in
Usage Attribution.
Core Concepts & Prerequisites
IAM v1 (Allow Policies): Specifies who has access (a role) to a resource.
Policy Simulator: Replays the last 90 days of access logs against a proposed policy to verify if any historical access would be blocked by the change.
Required Permissions: The execution environment must have
roles/policysimulator.admin,roles/cloudasset.viewer, and the appropriate IAM Admin roles for the target resource.Resource Scope: Changes can target Projects, Folders, or Organizations.
Execution Workflow: Plan, Simulate, Analyze, Apply
Step 1: Retrieve Current Policy (Plan)
Fetch the baseline IAM v1 policy for the target resource (Project, Folder, or
Organization) and save it to the /tmp/ directory:
For Projects:
gcloud projects get-iam-policy TARGET_PROJECT_ID --format=json > /tmp/current_policy.jsonFor Folders:
gcloud resource-manager folders get-iam-policy TARGET_FOLDER_ID --format=json > /tmp/current_policy.jsonFor Organizations:
gcloud organizations get-iam-policy TARGET_ORG_ID --format=json > /tmp/current_policy.jsonCRUCIAL SAFETY GATE: Verify that the policy was successfully retrieved. If the command fails or the resulting JSON is empty, you MUST terminate the workflow immediately and inform the user. Do not proceed to prepare or simulate an empty or partial policy.
Step 2: Prepare Proposed Policy
Create a /tmp/proposed_policy.json file. Modify /tmp/current_policy.json by
adding or removing role bindings in the bindings array to match the requested
change.
CRUCIAL NO-OP CHECK: Compare the proposed policy to the current policy. If no changes were actually made (e.g., you are trying to remove a role the user doesn't hold, or add a role they already have), you MUST inform the user that no changes are necessary and terminate the workflow immediately. Do not run a simulation.
Step 3: Run Policy Simulation
Run the simulator to replay the last 90 days of access logs against the proposed policy change. Execute the exact command for your resource type:
For Projects:
gcloud iam simulator replay-recent-access //cloudresourcemanager.googleapis.com/projects/TARGET_PROJECT_ID /tmp/proposed_policy.json --project=TARGET_PROJECT_ID --format=json > /tmp/simulation_results.jsonFor Folders:
gcloud iam simulator replay-recent-access //cloudresourcemanager.googleapis.com/folders/TARGET_FOLDER_ID /tmp/proposed_policy.json --format=json > /tmp/simulation_results.jsonFor Organizations:
gcloud iam simulator replay-recent-access //cloudresourcemanager.googleapis.com/organizations/TARGET_ORG_ID /tmp/proposed_policy.json --format=json > /tmp/simulation_results.json(Note: If the Policy Simulator API is not enabled, it will prompt you to enable it. Select Yes. Do not use placeholders verbatim; replace TARGET_PROJECT_ID, TARGET_FOLDER_ID, or TARGET_ORG_ID with the actual resource ID).
CRUCIAL SAFETY GATE: Verify the command exited successfully. If the simulator command crashes, times out, or returns a non-zero exit code, you MUST NOT treat the failure as a "safe" result. Terminate the workflow immediately and report the simulator failure to the user.
Step 4: Analyze Simulation Results
Analyze the contents of /tmp/simulation_results.json using the provided helper
script. Do not write custom scripts on the fly. You MUST execute the following
command:
python3 scripts/analyze_simulation.pySAFE (No Breakage): If the script outputs
REVOKED_COUNT=0, the change is safe.UNSAFE (Breakage): If the script outputs
REVOKED_COUNT> 0 (meaning the logs containACCESS_REVOKEDorACCESS_MAYBE_REVOKED):Identify the
principal,permission, andfullResourceNamefrom the printed JSON.Do NOT apply the policy.
The change will break an active workload. Inform the user of the specific disrupted accesses.
Step 5: Apply Policy (Only if Safe)
If and only if the simulation in Step 4 was SAFE (No Breakage), prompt the user: "The simulation showed no disrupted access. Do you want to apply this policy change? (Yes/No)".
If Yes: Apply the policy using the correct command for the resource type:
For Projects:
gcloud projects set-iam-policy TARGET_PROJECT_ID /tmp/proposed_policy.jsonFor Folders:
gcloud resource-manager folders set-iam-policy TARGET_FOLDER_ID /tmp/proposed_policy.jsonFor Organizations:
gcloud organizations set-iam-policy TARGET_ORG_ID /tmp/proposed_policy.jsonIf No: Terminate the workflow.
Step 6: Cleanup (Always Run)
After applying the policy, declining the prompt, or terminating early due to a NO-OP/failure, always delete the temporary files to prevent cross-contamination in future runs:
rm -f /tmp/current_policy.json /tmp/proposed_policy.json /tmp/simulation_results.jsonFiles
- ATTRIBUTION.mdAdded by AutoGineer880 B
- LICENSELicence file added by AutoGineer11.1 KiB
- SKILL.md6.0 KiB
- references/attribution.md1.9 KiB
- scripts/analyze_simulation.pyScript1.3 KiB
Requirements and compatibility
Works with: Claude Code, Claude apps, OpenAI Codex, GitHub Copilot, Cursor, Gemini CLI, Kiro, OpenCode, Goose, Amp, Roo Code, JetBrains Junie, Factory Droid, Devin (ex-Windsurf), Mistral Vibe, OpenHands, Letta
“Works with” means the tool reads the open Agent Skills format; a skill written for one tool may use features others lack.
Needs: Needs a command-line tool, Needs Python
Security
What our scanner noticed· Low risk
- Scripts that your agent may run
This skill includes scripts that your agent may run. Read them before you use it.
A static scan is not a guarantee. Skills are third-party content: review a skill before you let an agent use it.
Attribution and licence
- Published by
- Publisher
- Google (Official)
- Source
- google/skills · skills/cloud/iam-helper-for-policy-simulator · commit 2194d3b
- Licence
- Apache License 2.0 (redistribution allowed)
- LICENSE (added by AutoGineer from LICENSE)
- ATTRIBUTION.md (written by AutoGineer)
- Synced
AutoGineer is not affiliated with or endorsed by Google.
Download ZIP
The ZIP holds the skill’s files, its licence files and an ATTRIBUTION.md. Download iam-helper-for-policy-simulator.zip