본문으로 건너뛰기
Skillpedia
보안22k · #10339

iam-helper-for-policy-simulator

하는 일

이 스킬은 실서비스에 적용되기 전에 IAM 정책 변경을 확인하여, 사람들이 지금 쓰는 접근을 막지 않도록 합니다. 변경이 안전한지 확신하고 싶은 관리자를 위한 스킬입니다.

사용하는 경우

  • ✓프로젝트, 폴더 또는 조직의 IAM v1 허용 정책을 바꾸려고 할 때.
  • ✓제안된 역할 변경이 과거 접근을 막는지 확인하고 싶을 때.
  • ✓실사용 워크로드를 깨뜨리지 않고 IAM 변경을 적용할 안전한 방법이 필요할 때.

스킬 링크

https://github.com/google/skills/blob/main/skills/cloud/iam-helper-for-policy-simulator/SKILL.md

복사해서 AI(Claude, ChatGPT, Cursor)에 붙여넣고 지침을 따르도록 요청하세요.

사용 방법

가장 쉬운 방법입니다. 메시지를 복사해 AI에 붙여넣으세요. AI가 스킬을 읽고 지침을 따릅니다.

바로 붙여넣을 수 있는 메시지

Use this skill to help me: https://github.com/google/skills/blob/main/skills/cloud/iam-helper-for-policy-simulator/SKILL.md Read the SKILL.md file at that link and follow its instructions for my task.
AI가 이런 스킬을 알아서 찾아 쓰길 원하시나요?무료 Skillpedia MCP를 설치하세요. 한 줄이면 작업마다 스킬 15,000+개 중에서 검색합니다.1분 만에 설치 →

AI에게 요청하는 예시

“이 그룹에서 editor 역할을 제거하기 전에, 시뮬레이터로 실제로 쓰고 있는 접근을 잃을 사람이 있는지 확인해 주세요.”

매주 새 스킬 5개. 읽는 데 1분.

작동 방식

현재 정책을 저장하고, Policy Simulator로 최근 접근 로그를 제안된 변경에 대입해 재생한 다음, 막히게 될 과거 접근을 보고합니다. 그 뒤에만 변경 적용을 돕습니다.

기술 내용 (원본 SKILL.md)

작성자의 영어 원문을 GitHub에서 그대로 가져왔습니다.

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.json

For Folders:

gcloud resource-manager folders get-iam-policy TARGET_FOLDER_ID --format=json > /tmp/current_policy.json

For Organizations:

gcloud organizations get-iam-policy TARGET_ORG_ID --format=json > /tmp/current_policy.json

CRUCIAL 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.json

For Folders:

gcloud iam simulator replay-recent-access //cloudresourcemanager.googleapis.com/folders/TARGET_FOLDER_ID /tmp/proposed_policy.json --format=json > /tmp/simulation_results.json

For 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.py
  • SAFE (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 contain ACCESS_REVOKED or ACCESS_MAYBE_REVOKED):
    • Identify the principal, permission, and fullResourceName from the printed JSON.
    • Do NOT apply the policy.
    • The change will break an active workload. In
자주 묻는 질문

접근 기록을 얼마나 거슬러 보나요?

최근 90일의 접근 로그를 재생합니다.

테스트 없이 변경을 적용하나요?

아닙니다. 시뮬레이션을 먼저 실행하지 않고 변경을 적용하지 않습니다.

거부 정책도 다루나요?

아닙니다. IAM v2 거부 정책 분석은 범위 밖입니다.

상세 정보

작성자의 원본 설명

Safely simulates and applies Identity and Access Management (IAM) v1 (Allow) policy changes on Google Cloud. Uses the Policy Simulator to replay historical access logs against proposed policies to prevent breaking active workloads before applying the changes. Use when simulating or applying IAM v1 allow policies across Projects, Folders, or Organizations. Don't use for analyzing IAM v2 deny policies, VPC Service Controls, or performing general policy troubleshooting.

repo: google/skills

인기도

GitHub 스타
22k
순위
#10339
라이선스
Apache-2.0
업데이트
2026. 11. 2.

이 스킬이 유용한가요?

0

로그인 투표하려면 로그인하세요.

댓글

  • …

이 저장소의 다른 스킬

비슷한 스킬